From patchwork Mon Jul 1 02:51:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 808826 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1376561wrr; Sun, 30 Jun 2024 19:52:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXtHe9jE7xv8lmQkNG6iQnehJK1uSubfQla+P9LP63i3Q20vf0p5/UxZG1vwk+GSu55k9P13sgaOs2t3LTjo2iM X-Google-Smtp-Source: AGHT+IH/GuE5z0SNiduann71GhT6+05nkPi1XGhyPJcFsQ66uEmLo4Ep+gjZsGq7Y/6CDfCTYD7p X-Received: by 2002:a05:6214:ccd:b0:6b5:4bf8:57f0 with SMTP id 6a1803df08f44-6b5b716bfe1mr54937406d6.48.1719802365358; Sun, 30 Jun 2024 19:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719802365; cv=none; d=google.com; s=arc-20160816; b=jpKfO7binuXl2CtUBvJKMpDMzjyO9ZC4Gw+KD/lopj2SNAd9c9XY7zcMiA7YDLiPvL JMQgF2NTj+bZweujuKtpLRRhwaG0G1ogwMCCVTnmRSEIkYkUUvnFZxseWsJt6JS3ImY0 tVEX12LYpSueuJjj+nVNsOk8XOUDu7h0uE6mzqjOw1xtQTWT/nRSX5FPIBISIXoV8DBv ofheDcW20VqFbZZMOH/YGGvD8cIOGIzf6F5MXZlItkpb0yZjhOb92JqdF0p4bqw/GF63 xhH008ZwZvF/HlBXmNVq1FLbuYR6/1q3HjovFyIqj8JAcff+vy2+kqtStXsmpV8A8UVz rMHg== 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=5uYPQnTpDkityzLolaGQ63NdFXXcedgiMTlSb315wZQ=; fh=3mEp7FusppN5Drq2PN08R8D/9xXM9YdbtG5TkJxJBiE=; b=z5FXKG7NKmTkYW0wHq8CoxOpKsvDUsMdG2P12VjnX40BgIEV9IehY6Tnk4q1yVUs0B 1uC867k886AuwDjOh2v5BI/rM7VgLdWf8S5zSIDVtDAhciliEo2y0Ka0URxcCT50pKg1 nQqZLOEFwp5JJBXcFvdc6ISh7WlC1UfmV+R9WOSS3AeVs4I/4BqWv7KH1rRHidsD0UuB teU5zYpgx2oQWfRxLVfxPga2oRLAKfRysTFxUCO1mves+T87VtxsB5J7AYLIfgoiAWOi lbYzrLKWp5vZFzg/oF3BG8KAcGuP5HBwsHqdZJvmEmBtH/kZ9FnIsD9E63X8n23SiDgq HoJA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AGQf/h9T"; 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 6a1803df08f44-6b59e5ad3cfsi73751456d6.280.2024.06.30.19.52.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jun 2024 19:52:45 -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="AGQf/h9T"; 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 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 { }; /* Bit set if the global variable is live after setting CC_OP to X. */ -static const uint8_t cc_op_live[CC_OP_NB] = { - [CC_OP_DYNAMIC] = USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, - [CC_OP_EFLAGS] = USES_CC_SRC, - [CC_OP_MULB ... CC_OP_MULQ] = USES_CC_DST | USES_CC_SRC, - [CC_OP_ADDB ... CC_OP_ADDQ] = USES_CC_DST | USES_CC_SRC, - [CC_OP_ADCB ... CC_OP_ADCQ] = USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, - [CC_OP_SUBB ... CC_OP_SUBQ] = USES_CC_DST | USES_CC_SRC | USES_CC_SRCT, - [CC_OP_SBBB ... CC_OP_SBBQ] = USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, - [CC_OP_LOGICB ... CC_OP_LOGICQ] = USES_CC_DST, - [CC_OP_INCB ... CC_OP_INCQ] = USES_CC_DST | USES_CC_SRC, - [CC_OP_DECB ... CC_OP_DECQ] = USES_CC_DST | USES_CC_SRC, - [CC_OP_SHLB ... CC_OP_SHLQ] = USES_CC_DST | USES_CC_SRC, - [CC_OP_SARB ... CC_OP_SARQ] = USES_CC_DST | USES_CC_SRC, - [CC_OP_BMILGB ... CC_OP_BMILGQ] = USES_CC_DST | USES_CC_SRC, - [CC_OP_ADCX] = USES_CC_DST | USES_CC_SRC, - [CC_OP_ADOX] = USES_CC_SRC | USES_CC_SRC2, - [CC_OP_ADCOX] = USES_CC_DST | USES_CC_SRC | USES_CC_SRC2, - [CC_OP_CLR] = 0, - [CC_OP_POPCNT] = 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(); + } +} 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) } /* Discard CC computation that will no longer be used. */ - dead = cc_op_live[s->cc_op] & ~cc_op_live[op]; + dead = 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 = cpu_cc_src2; /* Take care to not read values that are not live. */ - live = cc_op_live[s->cc_op] & ~USES_CC_SRCT; + live = cc_op_live(s->cc_op) & ~USES_CC_SRCT; dead = live ^ (USES_CC_DST | USES_CC_SRC | USES_CC_SRC2); if (dead) { TCGv zero = 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 = cc_op_live[decode.cc_op]; + cc_live = cc_op_live(decode.cc_op); } else { cc_live = 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 = tcg_temp_new_i32(); TCGv_i32 old_cc_op; + uint8_t live; decode->cc_op = CC_OP_DYNAMIC; decode->cc_op_dynamic = tcg_temp_new_i32(); assert(decode->cc_dst == s->T0); - if (cc_op_live[s->cc_op] & USES_CC_DST) { + live = cc_op_live(s->cc_op); + if (live & USES_CC_DST) { decode->cc_dst = tcg_temp_new(); tcg_gen_movcond_tl(TCG_COND_EQ, decode->cc_dst, count, tcg_constant_tl(0), cpu_cc_dst, s->T0); } - 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_constant_tl(0), cpu_cc_src, decode->cc_src); }