From patchwork Wed Oct 25 07:26:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 737831 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp148922wrq; Wed, 25 Oct 2023 00:28:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9xYRtSk8+Zp1Xs4P2yxRXTNbPdvOZv+oLRuAdhKl2Iy8HM3H0aRINNi4pM0fqzhuGpt0H X-Received: by 2002:a05:6214:d8a:b0:65b:216f:2d65 with SMTP id e10-20020a0562140d8a00b0065b216f2d65mr17617079qve.5.1698218893862; Wed, 25 Oct 2023 00:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698218893; cv=none; d=google.com; s=arc-20160816; b=vNFi4QhdfJ9I42k+KxLk7j4QybaBT8zbmPMeDieLgpwRA/oXkiWVRVvJypYMDx0pHF lZejTE47D//RR0ATT77cQM9KvB8GIMwwW413wbEAO/0SdqsW/9ci7X8JjtxZSgs6EE4g hexEm28o2E6U06Bdf4IZlW06AMT3ZfvhUGDs50LwpR7Sa7pwYehEDk58N/g7Pvt7mqCg jq5FQ3XWv3V80wWpu3ex3IlsO+fPZhwMaqOpsycxLiT0/DY9hOzy7YSlZ3c/qhVic92i vriwlu09c1PT3LERygIiOcKCpGPU5I+QgfZHoxpqGspUX2joqaSBLKJbvNAZgNqF7ZPx dtVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Dcov+EvgUKOcstVsIicTu1476ZKJilrV5KBfm5f0U0k=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=SWnK6aEFNpQoFL+0xyIhi1MiE90aFTZ9PXID/VJmxKyyrIggBI6IPyzjRaToqdcJfq 1dqe4qqbT0/sZQNF3Iai4+HLQidIHPZO92Chtsk63DcBJu2qrGOQ1vvXZT9G3LfCXEYy OdsWLhbICBdHtYJ2MmwI8CCKcZ1VBKKa4aWABat29JryHCCO8nAprbv9vnGEtq0jI/hl SyVS084vf2XYL6jJ4pE0dG9/sgO3M4RGbGMQIzupUXT0SniMWNtBY36E+y7wDy5u5lxh PAJ6NrUu3/z8Um3cdmtEJ5H+a6paADf3IXao2lLFkdTI29ZolfL88NJ4z5B2yVjn7dVr +CPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=exh3C+XX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m2-20020ad44b62000000b0065d0358ebc5si8203424qvx.394.2023.10.25.00.28.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2023 00:28:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=exh3C+XX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvYIU-0000Cb-Te; Wed, 25 Oct 2023 03:27:22 -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 1qvYIQ-00009V-Sp for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:18 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvYIK-0004db-5A for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:17 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c434c33ec0so36548665ad.3 for ; Wed, 25 Oct 2023 00:27:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698218830; x=1698823630; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Dcov+EvgUKOcstVsIicTu1476ZKJilrV5KBfm5f0U0k=; b=exh3C+XXiFHqM3rIifHe65l55SDnpxZ/xfkSMjnh3sUiRVbUoIzGubbD0w/oh+u4jU SndYaJwkP/vW3toyvskRbQ89QwCZHvy2mCbPa+nM0q9rahHiazbQbaV15mNR+bOmmVE/ FH6Dez1pgCeVPH8xztKsZb8Ij/6Fsibvy6rg69pxOYjWTtlU1C6lusDgXUlaTEbWNSb0 CUbEYsh4Ixr7DXYOHzEZxo7wspeixyY8Oe9zHj0arc+MxSFEJp64CP5OWNoFZGNDRiZz UBFQ+5zGhNEHNm6iTXtbnnR3md+hBbuM8wzvnlPOorlD+bJgZRj2rvS0UF8jD+te2azx WTVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698218830; x=1698823630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dcov+EvgUKOcstVsIicTu1476ZKJilrV5KBfm5f0U0k=; b=smYVHbK9AXxu0FjtJSkx3LofB5cQe8GGp1icd2oTM4y0aWfMfl+2xfxAY06NZQwLPr GyRimFoNK+Cj6xyuXrulG93IrhPAuUO7qPgACTxmkeE5e4ij0ne2v7NtCQ0syedIRK4f sRXLAfJqQYlKvckZPTAV9rkTJyyILUjq6gRRTkIWwV+Bk00AIWEhiQarKQonwVz7+oH1 EGkXn90+fQCwC7Eij1JTByyQPs4T2enNxHNjdH9AIvt2tkA6gdSTXioyrOpQSGoQ+qAl xP/K4U5KIkbEN1FsokQ25WFAyTPAXugMJWoRWo4Z5a3BRbg64CjnXoJwkVOfETF/tzsp b4Wg== X-Gm-Message-State: AOJu0YxSyY5veluBwemniTZmVTTQx+31m/CaioSu1watUtcXLnOkYurU /A1E0E1lk9E8laSeDtfaRgvFdBWo2/SORefsLOE= X-Received: by 2002:a17:902:db0c:b0:1ca:7909:6ee6 with SMTP id m12-20020a170902db0c00b001ca79096ee6mr12190819plx.61.1698218829753; Wed, 25 Oct 2023 00:27:09 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id ji5-20020a170903324500b001b06c106844sm8578661plb.151.2023.10.25.00.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 00:27:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 01/29] tcg: Introduce TCG_COND_TST{EQ,NE} Date: Wed, 25 Oct 2023 00:26:39 -0700 Message-Id: <20231025072707.833943-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025072707.833943-1-richard.henderson@linaro.org> References: <20231025072707.833943-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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, T_SPF_TEMPERROR=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 = 0 | 4 | 0 | 1, TCG_COND_LEU = 8 | 4 | 0 | 0, TCG_COND_GTU = 8 | 4 | 0 | 1, + /* "test" i.e. and then compare vs 0 */ + TCG_COND_TSTEQ = 8 | 4 | 2 | 0, + TCG_COND_TSTNE = 8 | 4 | 2 | 1, } TCGCond; /* 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; } -/* 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) == 2; } /* Must a comparison be considered unsigned? */ static inline bool is_unsigned_cond(TCGCond c) { - return (c & 4) != 0; + return (c & 6) == 4; +} + +/* Must a comparison be considered a test? */ +static inline bool is_tst_cond(TCGCond c) +{ + return (c | 1) == 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; } /* 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[] = [TCG_COND_LTU] = "ltu", [TCG_COND_GEU] = "geu", [TCG_COND_LEU] = "leu", - [TCG_COND_GTU] = "gtu" + [TCG_COND_GTU] = "gtu", + [TCG_COND_TSTEQ] = "tsteq", + [TCG_COND_TSTNE] = "tstne", }; static const char * const ldst_name[(MO_BSWAP | MO_SSIZE) + 1] = 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 == 0 */`` + | ``TCG_COND_TSTNE /* t1 & t2 != 0 */`` Arithmetic ----------