From patchwork Wed Oct 25 07:26:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 737851 Delivered-To: patch@linaro.org Received: by 2002:adf:f842:0:b0:32d:baff:b0ca with SMTP id d2csp150456wrq; Wed, 25 Oct 2023 00:33:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZq4/cm95a4qe0NQNneVe/gpWdMwD12r+AZQr6/w8Njj90UjyzI4/HaD0vD7QoGXKexfHY X-Received: by 2002:ac8:5d8f:0:b0:41e:1eb2:6265 with SMTP id d15-20020ac85d8f000000b0041e1eb26265mr10568973qtx.67.1698219183054; Wed, 25 Oct 2023 00:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698219183; cv=none; d=google.com; s=arc-20160816; b=ZA4JzCJlxDWcDLO3mvvKdZk3zl+qqo+HbUaG9ycOl+S2SB0lo7fGfo57/oGxWAMHFa /2xKZdnKV963ctp1eLUR1njy0BuNmYgpfHzqtuLomL9mhXWMDICho/ROJ48BiNyi+g4B mO62NQ8Wo6GtcUFQH8//FdmXMGJ6zcircyeRDsJvskMeNjUtayhRb4+SL4iVeQhaXZOe 4E0CMRo3L3NF9I2mDopjCS9mZPp2GZDL9Uz3h48CiPYq9sl690VWL6tR967yu0RBlV0q Ns1wZjwwziFib7pGMCAKyR2wb0S5V0NR8jYsgmU18W/8ULnLnkDQVbR+jaicfUTicxrP ptaA== 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=KAuC6MuCUKIHHBxqGTcvXulP9OV1zIYTQIpMzlqMLcg=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=YFVmWcK3INspLOP2r+gyIUt1wDVRpYr3tmcqbZ0huS6yIo8N2QU9KM93Pt5UuH7bFz gDpG9HXWfpEdpbHoNjSn+gGSzaoWJF3JeSw/2OmLHBsb4rKLC0zS+a9+aJxZh0tYqudF EQOz/Zzvqz50XtmwKsq50pzAW9qTTBDyvMc3cpbSU5on84aMwNhO8oL07cd6OWIt9bfe Kjzq1XMy7bsE6VDggdPsckoA2aRHuXPjd8b2h93waJw+h1CH0zR53VUdH3aSsux7lJwG 12fwwfTtA4EXcxCtwimxF6TimMUWpfWO48CO3IDIEAROscV2OGR78MY0oeM0GZ2MX/JE mKfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="aJ/xFwXw"; 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 e13-20020ac8490d000000b0041cd6a52911si7810640qtq.736.2023.10.25.00.33.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2023 00:33:03 -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="aJ/xFwXw"; 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 1qvYIX-0000EW-AF; Wed, 25 Oct 2023 03:27:25 -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 1qvYIU-0000CS-6j for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:22 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvYIS-0004gD-Jj for qemu-devel@nongnu.org; Wed, 25 Oct 2023 03:27:21 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c9bf22fe05so35210945ad.2 for ; Wed, 25 Oct 2023 00:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698218839; x=1698823639; 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=KAuC6MuCUKIHHBxqGTcvXulP9OV1zIYTQIpMzlqMLcg=; b=aJ/xFwXwEyhqg1DVIzg3QT9r7GDFD43iFOaql3C3XLdfyoVXoH2vBTCJyrbtbtIdvD nyWq4fVjDeWoidvmkloeH6R5ZQODmVbSaqEK3hNYFDJ0ZQZl6knPmqcQ9Z78Oc+MjFwj ASeYvOIgglRYgIdeeIZ8CxVDN45UBx1XJo7vjkgFt9WyQu8jfgJiA48P/+msP1B9hjNT roJRiVjaH077TQZg0RRiHQ7y3xBIT0PpB3GWlhNThKLW926LOFKlIMbiNYpf5RhShZx4 qTnnjvBXuqT3qxl0lKPXt/heNu0bsEnPG4YqrbkiwtDG2lNGiWb3quxPB6l3zTRGlBbk 2UWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698218839; x=1698823639; 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=KAuC6MuCUKIHHBxqGTcvXulP9OV1zIYTQIpMzlqMLcg=; b=ZUkbPRtl7g/A+9961zbVqS2qCLINmpENq/nG+LspFYgmct5JX5XYW2deC8W7NRf/8w NECHuGzbj3D6GF4nQRUewRwYJv76UVLtuRAFGlysynWvlir2SPAJtYikWdniSns2S+5A qNrNw2VVwbl7K2Ft64HeoPndYF83F95lQkLyKsc8xY2pnrBbS8tDhthXZGXUyDCShjPq U5huAynpWd9R6iFAKApe9pXE+8qkja5yiBE1ZCuczc2rp9IeSSxEmybtIgawrM6OrCLM E5vlyejQ0LsWHDfVsu2z0mmR8sDi4nMqFS4uDV7o9ordnEwtiStuxAFrcK1rTyv3fkLu 7CEA== X-Gm-Message-State: AOJu0YxvI4+KQtTRfJP+3hgJbfuZKBdSBoVh85McD1PLQjQQygd2tLFz LvN9X2Iwms+wsWNbCWmmRmDH7RH1IFs2sh+O1u8= X-Received: by 2002:a17:902:e391:b0:1ca:678b:5764 with SMTP id g17-20020a170902e39100b001ca678b5764mr8359147ple.54.1698218839334; Wed, 25 Oct 2023 00:27:19 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id ji5-20020a170903324500b001b06c106844sm8578661plb.151.2023.10.25.00.27.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 00:27:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 11/29] tcg/i386: Move tcg_cond_to_jcc[] into tcg_out_cmp Date: Wed, 25 Oct 2023 00:26:49 -0700 Message-Id: <20231025072707.833943-12-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Return the x86 condition codes to use after the compare. Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 0daffb0e70..6e8af1fcf6 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1418,8 +1418,8 @@ static void tcg_out_jxx(TCGContext *s, int opc, TCGLabel *l, bool small) } } -static void tcg_out_cmp(TCGContext *s, TCGArg arg1, TCGArg arg2, - int const_arg2, int rexw) +static int tcg_out_cmp(TCGContext *s, TCGCond cond, TCGArg arg1, + TCGArg arg2, int const_arg2, int rexw) { if (const_arg2) { if (arg2 == 0) { @@ -1431,14 +1431,15 @@ static void tcg_out_cmp(TCGContext *s, TCGArg arg1, TCGArg arg2, } else { tgen_arithr(s, ARITH_CMP + rexw, arg1, arg2); } + return tcg_cond_to_jcc[cond]; } static void tcg_out_brcond(TCGContext *s, int rexw, TCGCond cond, TCGArg arg1, TCGArg arg2, int const_arg2, TCGLabel *label, bool small) { - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); - tcg_out_jxx(s, tcg_cond_to_jcc[cond], label, small); + int jcc = tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_jxx(s, jcc, label, small); } #if TCG_TARGET_REG_BITS == 32 @@ -1530,6 +1531,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, { bool inv = false; bool cleared; + int jcc; switch (cond) { case TCG_COND_NE: @@ -1566,7 +1568,7 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, * We can then use NEG or INC to produce the desired result. * This is always smaller than the SETCC expansion. */ - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); + tcg_out_cmp(s, TCG_COND_LTU, arg1, arg2, const_arg2, rexw); /* X - X - C = -C = (C ? -1 : 0) */ tgen_arithr(s, ARITH_SBB + (neg ? rexw : 0), dest, dest); @@ -1613,8 +1615,8 @@ static void tcg_out_setcond(TCGContext *s, int rexw, TCGCond cond, cleared = true; } - tcg_out_cmp(s, arg1, arg2, const_arg2, rexw); - tcg_out_modrm(s, OPC_SETCC | tcg_cond_to_jcc[cond], 0, dest); + jcc = tcg_out_cmp(s, cond, arg1, arg2, const_arg2, rexw); + tcg_out_modrm(s, OPC_SETCC | jcc, 0, dest); if (!cleared) { tcg_out_ext8u(s, dest, dest); @@ -1685,8 +1687,8 @@ static void tcg_out_movcond(TCGContext *s, int rexw, TCGCond cond, TCGReg dest, TCGReg c1, TCGArg c2, int const_c2, TCGReg v1) { - tcg_out_cmp(s, c1, c2, const_c2, rexw); - tcg_out_cmov(s, tcg_cond_to_jcc[cond], rexw, dest, v1); + int jcc = tcg_out_cmp(s, cond, c1, c2, const_c2, rexw); + tcg_out_cmov(s, jcc, rexw, dest, v1); } static void tcg_out_ctz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, @@ -1728,8 +1730,8 @@ static void tcg_out_clz(TCGContext *s, int rexw, TCGReg dest, TCGReg arg1, tgen_arithi(s, ARITH_XOR + rexw, dest, rexw ? 63 : 31, 0); /* Since we have destroyed the flags from BSR, we have to re-test. */ - tcg_out_cmp(s, arg1, 0, 1, rexw); - tcg_out_cmov(s, JCC_JE, rexw, dest, arg2); + int jcc = tcg_out_cmp(s, TCG_COND_EQ, arg1, 0, 1, rexw); + tcg_out_cmov(s, jcc, rexw, dest, arg2); } }