From patchwork Wed Jan 10 22:43:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761502 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp2114090wrz; Wed, 10 Jan 2024 14:51:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtCfIHJKGTS7zLLjuqkjQO0ZYUokazv1BLe59Y5xS/bm7NARiU3EI/3pTI+MdWwRvxByG6 X-Received: by 2002:a05:6808:4496:b0:3bb:d6f6:1a71 with SMTP id eq22-20020a056808449600b003bbd6f61a71mr479097oib.111.1704927114886; Wed, 10 Jan 2024 14:51:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704927114; cv=none; d=google.com; s=arc-20160816; b=yf3ZJa27Ie6ckJ4Ji1PrHDCAc1T46GkDNvrJF+YeikLAQ4Du+mzdLzDWOpMa5FhS4w IqVS1sIWAtnPTlQg1sEXjQ+N392wWsYp1D8hTvF7SfNYrktXHGsjaxPzQd69nfeVzef/ SUPagnKcIbvzLI3st44coJvQUUma9oZjaeRL97WpBfhtqFVS2EoBQhKSED2OrfYytQCp q4hEAzQD0YD5XTZvx72Zl4ZztGYtfCLDCnCQ/ALCXOU+ZGufUffGy0zs+RqM1q3OyWS9 uC5i4SQxNO576avdXHwbDOOdraS6lV0egrptDYWbgUBmRs7JOy8yrMeerdHZ7YCDrvAt Le6A== 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=SYMLLwA9gva4L4uzAlLYH7HUcuo07hrL8DJH/YZuBt8=; fh=GbSB792CRg76qyQfASHmg380JBauy2gTuYi49sbOwBU=; b=xtmuQ6n+W9eRhgqqElflcr3go4PrEuXYocFGDqpTF+OtI3C0U91iLV2vqvb8r4kjcG L/yO/g6UOrtL2dH5vqJrN/pirt9ktB14zFuYxa7wq7LpoI/HfBM/BSk6Z0t8R/5uQjra RG9Tcn34NeLM79HgRso/ZvR70BUXiHdsReW+kkh6e1PGHW+gWH0V+N3yCtlLiEpKzutv X2qIkS+ZVLByf8ATwtch3Fw3EB/V9cHNMXhuQbW6G5cW7L2PnZSWP99u2vT5yXS0dU5R PdHGXPEU0QfZNbh6y8CHSbxFtV5swjhrC67cOzx/eoNAhYBvq5kenwjDBO4WUHyXWCMg rB1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dOBJQBiX; 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 bd6-20020ad45686000000b00680cf7233dcsi5337038qvb.613.2024.01.10.14.51.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2024 14:51:54 -0800 (PST) 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=dOBJQBiX; 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 1rNhLM-0007bU-TB; Wed, 10 Jan 2024 17:46:41 -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 1rNhL0-0006ZQ-38 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:19 -0500 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNhKv-0003IX-UR for qemu-devel@nongnu.org; Wed, 10 Jan 2024 17:46:17 -0500 Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-dbed4b84667so4107654276.0 for ; Wed, 10 Jan 2024 14:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704926772; x=1705531572; 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=SYMLLwA9gva4L4uzAlLYH7HUcuo07hrL8DJH/YZuBt8=; b=dOBJQBiX7IGwYiMXLqNTLkmDTKZYaSsFNePeAVBSpSVxPRb75qp8eQcbDxVYai5pvW 0sbUu+f6+u1Nsi2xk+LmlVJygH/ujMiNxihSzNKqN4ETSmfgSTgpueWImCagcEEDDs+K 92JhcfI5mWsCs7jSkAo8TWfQVDF3cafgAC2XKpYRsghY3sr70BWz1J0k9IEmooNa16Fh wu+KjdMXYNWlHA9WWjyk82wB+dSlxCmwLGCERiQ0BOvtaNZi2PJfSimQjbO3RHTDj9Nd wsIkVi0Y8eMvk6p62cZ5rvHuhga0ZWXxvr6BkCuFLOgmW6eZ28CRdfAQ8ooFRBLrkBpm m16w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704926772; x=1705531572; 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=SYMLLwA9gva4L4uzAlLYH7HUcuo07hrL8DJH/YZuBt8=; b=jk0lh0Anl4xFShDtHG4R+Rf3A9urdQAk14BbBcjs8qaN0Fu/uqTqiJQEM7k05gGcX2 GKbrfiOWfzoatqaaS7BU/20WAfZtIAFDkA6FRdrzrZJxHEX8y+DtJYAhG/un6lvnVdYR RcsSuQaAIlU716aGWFSiMrdibs099dJxWe7TkwUw1S94Z6g/37GhwgEnc8I+2SreB4Sy oIRf94OQXCAEa8eizrf/0UZkkBBRop5Nhw2VN49j9HnKV08n6sUmDRAmyNMHUU4kbOPA XJQ1wKWHzHxACB+T+tJ29TrN/MLsZUqpKNcI7Cr2McO6OrBF0oqRS5CNan4sy8Mzk6t+ VVxQ== X-Gm-Message-State: AOJu0Yw5X5fl/ltFuic5fo9aefM9qdUhkNVi9M98XNXUfPZVzCDKcsBx rDNF0FqvFzF7abwR5WTeVrMVAY8tngDVJjWltJMJQ8NdEi3zDW6G X-Received: by 2002:a25:abc1:0:b0:dbe:a098:6cfc with SMTP id v59-20020a25abc1000000b00dbea0986cfcmr402400ybi.25.1704926771758; Wed, 10 Jan 2024 14:46:11 -0800 (PST) Received: from stoup.. ([172.58.27.160]) by smtp.gmail.com with ESMTPSA id ks23-20020ac86217000000b0042987f6874bsm2092281qtb.92.2024.01.10.14.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:46:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, pbonzini@redhat.com Subject: [PATCH v3 23/38] tcg/i386: Move tcg_cond_to_jcc[] into tcg_out_cmp Date: Thu, 11 Jan 2024 09:43:53 +1100 Message-Id: <20240110224408.10444-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240110224408.10444-1-richard.henderson@linaro.org> References: <20240110224408.10444-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b2d; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb2d.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Return the x86 condition codes to use after the compare. Reviewed-by: Philippe Mathieu-Daudé 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 2d6100a8f4..02718a02d8 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1449,8 +1449,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) { @@ -1462,14 +1462,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 @@ -1561,6 +1562,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: @@ -1597,7 +1599,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); @@ -1644,8 +1646,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); @@ -1716,8 +1718,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, @@ -1759,8 +1761,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); } }