From nobody Fri Oct 18 10:22:10 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=1719802365; cv=none; d=zohomail.com; s=zohoarc; b=P3xKity9Cf47NjDfU5ERjHLHcCdxaxvDAvH0UJVIWRA1MRmorCS0hnv7lJxB25mj65MoZx98VFQ/ajyNllPUGFTo9CWODmGoW16i/mWM8RtFenwbujAVNS0EXWIohthlnXKDtEWk0OGTnhHKvReMuROwiAdrwWBfu0inLqqGHl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719802365; 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=5uYPQnTpDkityzLolaGQ63NdFXXcedgiMTlSb315wZQ=; b=exjryzVTieTr1w5pNE9rycWGZFK06elwdCCsMvWr1jas7ogh2RZ75F3jj4KF1XaIUOgW+T7kED3kEc1jZeKJpzFbEWnD46heGoW6YXtEgvJSdg+4oBw7rmiaUKR8h3c7KYvXoAEsl/v3jTNSqsqiqR6+y+NMeRFyTUYPgea3ZhU= 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 1719802365656654.0375526863334; Sun, 30 Jun 2024 19:52:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sO78Z-00031u-Kk; Sun, 30 Jun 2024 22:51:27 -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 1sO78X-00030g-84 for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:25 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sO78S-0008Vs-2z for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:24 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-6bce380eb96so1308153a12.0 for ; Sun, 30 Jun 2024 19:51:19 -0700 (PDT) Received: from stoup.. (174-21-76-141.tukw.qwest.net. [174.21.76.141]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91d3b9349sm5531698a91.37.2024.06.30.19.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 19:51:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719802279; x=1720407079; 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=5uYPQnTpDkityzLolaGQ63NdFXXcedgiMTlSb315wZQ=; b=AGQf/h9Tm9ZDOHxbD7gnwh4KeCRPat0bH7RtRenbXXWduENbHx/E0RHyNXod69o4IS cx0YVkm0tLoiggEMM074mrfLEEbuj3zNZSlnyc7sy17l1yZ05Lf9gXL6GAqIYGY9TE33 HWxfypXIj/mg49yjgh6Aqd2HQOcVVAiUcOviBcueA5U/5XhuP0a7XidGyWB2CFiOQxFp SQjxfpJbH2+5MbVLklT+m5UzY9kv+eeFUaVgd3n0vIhK5bEXzW+9llmz1thOq+zuIYTD RRVirF5fQs7t6netCbJV6hNiqftPeEFWVjtlW20t2IkIrVgH1162pBt0rHh5jO+QZZGk Rp/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719802279; x=1720407079; 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=5uYPQnTpDkityzLolaGQ63NdFXXcedgiMTlSb315wZQ=; b=TdK5FFWK7KTLYgjZqPFAd5ir+FV0SldkY+mw6NSH1rWrhlYnKXLnzwWPcfGUL2oFQJ p1w/RZ+Xq3LRYCMXWhUyuG7B3wy6UsFsVUESylryXHqWQxb6e3a0NdYlzJkt53yw7Gcs v8Ing9Bf6WYFxA0Ox7O24fYcoK/x1iXypEGDu6e43oz/Mukpb+t6lpqQmu6ckLuZOheb elzU2P6FkZjPLU6dWDAjuXqjQ40ehxcMAdMuk9Jl2yIDOm/HfohgbAnkfJNGRU4zXbXO SkmLink9Z+NfnkHQzkIIS+WB6lrYM8dg3K6csqorg1o+zJBQk6YDZ/gbC4udkqQaJ6XI /eXQ== X-Gm-Message-State: AOJu0YyC70h0ComYR0ecY+Io2wDYcwhchA9ff9FyMMPgKQls9Ut4yq7E 0V+W+GGVzmcnLrn83Xz2sViswICZn/YvuTJVAkb4VjgDc6wl6wPPq2D1SzENNa1/mT59ZwNmh9R N X-Google-Smtp-Source: AGHT+IELSYvp+N+Rp7B7MSQP6p7wWyGbOrfSctWPobh4fogKBulgBP1/NNLgQNMrzTpYlzD8kQKiAg== X-Received: by 2002:a17:90a:f28b:b0:2c9:35c4:dabe with SMTP id 98e67ed59e1d1-2c93d786945mr1646441a91.44.1719802278376; Sun, 30 Jun 2024 19:51:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com Subject: [PATCH 2/5] target/i386: Convert cc_op_live to a function Date: Sun, 30 Jun 2024 19:51:12 -0700 Message-Id: <20240701025115.1265117-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240701025115.1265117-1-richard.henderson@linaro.org> References: <20240701025115.1265117-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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719802366237100001 Content-Type: text/plain; charset="utf-8" Assert that op is known. Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 56 +++++++++++++++++++------------- target/i386/tcg/decode-new.c.inc | 2 +- target/i386/tcg/emit.c.inc | 6 ++-- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 95bad55bf4..e5a8aaf793 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -290,26 +290,38 @@ enum { }; =20 /* Bit set if the global variable is live after setting CC_OP to X. */ -static const uint8_t cc_op_live[CC_OP_NB] =3D { - [CC_OP_DYNAMIC] =3D USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, - [CC_OP_EFLAGS] =3D USES_CC_SRC, - [CC_OP_MULB ... CC_OP_MULQ] =3D USES_CC_DST | USES_CC_SRC, - [CC_OP_ADDB ... CC_OP_ADDQ] =3D USES_CC_DST | USES_CC_SRC, - [CC_OP_ADCB ... CC_OP_ADCQ] =3D USES_CC_DST | USES_CC_SRC | USES_CC_SR= C2, - [CC_OP_SUBB ... CC_OP_SUBQ] =3D USES_CC_DST | USES_CC_SRC | USES_CC_SR= CT, - [CC_OP_SBBB ... CC_OP_SBBQ] =3D USES_CC_DST | USES_CC_SRC | USES_CC_SR= C2, - [CC_OP_LOGICB ... CC_OP_LOGICQ] =3D USES_CC_DST, - [CC_OP_INCB ... CC_OP_INCQ] =3D USES_CC_DST | USES_CC_SRC, - [CC_OP_DECB ... CC_OP_DECQ] =3D USES_CC_DST | USES_CC_SRC, - [CC_OP_SHLB ... CC_OP_SHLQ] =3D USES_CC_DST | USES_CC_SRC, - [CC_OP_SARB ... CC_OP_SARQ] =3D USES_CC_DST | USES_CC_SRC, - [CC_OP_BMILGB ... CC_OP_BMILGQ] =3D USES_CC_DST | USES_CC_SRC, - [CC_OP_ADCX] =3D USES_CC_DST | USES_CC_SRC, - [CC_OP_ADOX] =3D USES_CC_SRC | USES_CC_SRC2, - [CC_OP_ADCOX] =3D USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, - [CC_OP_CLR] =3D 0, - [CC_OP_POPCNT] =3D USES_CC_DST, -}; +static uint8_t cc_op_live(CCOp op) +{ + switch (op) { + case CC_OP_CLR: + return 0; + case CC_OP_EFLAGS: + return USES_CC_SRC; + case CC_OP_POPCNT: + case CC_OP_LOGICB ... CC_OP_LOGICQ: + return USES_CC_DST; + case CC_OP_MULB ... CC_OP_MULQ: + case CC_OP_ADDB ... CC_OP_ADDQ: + case CC_OP_INCB ... CC_OP_INCQ: + case CC_OP_DECB ... CC_OP_DECQ: + case CC_OP_SHLB ... CC_OP_SHLQ: + case CC_OP_SARB ... CC_OP_SARQ: + case CC_OP_BMILGB ... CC_OP_BMILGQ: + case CC_OP_ADCX: + return USES_CC_DST | USES_CC_SRC; + case CC_OP_ADOX: + return USES_CC_SRC | USES_CC_SRC2; + case CC_OP_SUBB ... CC_OP_SUBQ: + return USES_CC_DST | USES_CC_SRC | USES_CC_SRCT; + case CC_OP_DYNAMIC: + case CC_OP_ADCB ... CC_OP_ADCQ: + case CC_OP_SBBB ... CC_OP_SBBQ: + case CC_OP_ADCOX: + return USES_CC_DST | USES_CC_SRC | USES_CC_SRC2; + default: + g_assert_not_reached(); + } +} =20 static void set_cc_op_1(DisasContext *s, CCOp op, bool dirty) { @@ -320,7 +332,7 @@ static void set_cc_op_1(DisasContext *s, CCOp op, bool = dirty) } =20 /* Discard CC computation that will no longer be used. */ - dead =3D cc_op_live[s->cc_op] & ~cc_op_live[op]; + dead =3D cc_op_live(s->cc_op) & ~cc_op_live(op); if (dead & USES_CC_DST) { tcg_gen_discard_tl(cpu_cc_dst); } @@ -816,7 +828,7 @@ static void gen_mov_eflags(DisasContext *s, TCGv reg) src2 =3D cpu_cc_src2; =20 /* Take care to not read values that are not live. */ - live =3D cc_op_live[s->cc_op] & ~USES_CC_SRCT; + live =3D cc_op_live(s->cc_op) & ~USES_CC_SRCT; dead =3D live ^ (USES_CC_DST | USES_CC_SRC | USES_CC_SRC2); if (dead) { TCGv zero =3D tcg_constant_tl(0); diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.= c.inc index 0d846c32c2..ba4b8d16f9 100644 --- a/target/i386/tcg/decode-new.c.inc +++ b/target/i386/tcg/decode-new.c.inc @@ -2792,7 +2792,7 @@ static void disas_insn(DisasContext *s, CPUState *cpu) tcg_gen_mov_i32(cpu_cc_op, decode.cc_op_dynamic); } set_cc_op(s, decode.cc_op); - cc_live =3D cc_op_live[decode.cc_op]; + cc_live =3D cc_op_live(decode.cc_op); } else { cc_live =3D 0; } diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index fc7477833b..38b399783e 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -3531,18 +3531,20 @@ static void gen_shift_dynamic_flags(DisasContext *s= , X86DecodedInsn *decode, TCG { TCGv_i32 count32 =3D tcg_temp_new_i32(); TCGv_i32 old_cc_op; + uint8_t live; =20 decode->cc_op =3D CC_OP_DYNAMIC; decode->cc_op_dynamic =3D tcg_temp_new_i32(); =20 assert(decode->cc_dst =3D=3D s->T0); - if (cc_op_live[s->cc_op] & USES_CC_DST) { + live =3D cc_op_live(s->cc_op); + if (live & USES_CC_DST) { decode->cc_dst =3D tcg_temp_new(); tcg_gen_movcond_tl(TCG_COND_EQ, decode->cc_dst, count, tcg_constan= t_tl(0), cpu_cc_dst, s->T0); } =20 - if (cc_op_live[s->cc_op] & USES_CC_SRC) { + if (live & USES_CC_SRC) { tcg_gen_movcond_tl(TCG_COND_EQ, decode->cc_src, count, tcg_constan= t_tl(0), cpu_cc_src, decode->cc_src); } --=20 2.34.1