From patchwork Mon Jul 1 02:51:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 808822 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1376376wrr; Sun, 30 Jun 2024 19:51:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWf3OaAmfTZgrcC/bMeeWTfwZxTvVsVh/42VPhY4Vb0zKM2CIIDIObhSdM7OjOjILVlbxDSGiKfIBxLX4OAW+Y8 X-Google-Smtp-Source: AGHT+IH6QdFlZG9nJTL2X7HZWhWMfwFV+xskDXn3D6mPKCdUtgf3Jkw+HQeAS1Rozc71JfE5rsR6 X-Received: by 2002:a81:9215:0:b0:618:2f6d:ca80 with SMTP id 00721157ae682-64c71802f91mr49244107b3.12.1719802308446; Sun, 30 Jun 2024 19:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719802308; cv=none; d=google.com; s=arc-20160816; b=lwqSprIHu3D0QaewcKmj3JQiVtVzn9hDAmxGMYd5jqbOrqjzg5QDh5LdSj9mBqDI/2 oCV4VUVF6w2Xfb5V7edXWcuW4DAyGmB5cCO80x8cTYCjUgMOaaiKlhFgfHJqJvjUJnw2 /FEcKYz9RINs2Pv25UQPP3Amz3TRIFt7nFWZos7qHctyAhe1lDjV3zMf4Vv6cVDD0JhV TjcVfZsG6uew3gY/cVn7O4T7373IWJZA8mRVVxusSq4cLVUDkKTsiR3nKUrrxmyrUUDx r7LcZFiHMUOu2SOLDxF622aZZM7Y3SpHU4CJKfBmR7chde0vVJtL85n/YftdlTbd3t4z iCxA== 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=mPMDVI+D07uyiyyk8Iq5xR3y1Ye6RQN5Bs9ydJnDyA0=; fh=3mEp7FusppN5Drq2PN08R8D/9xXM9YdbtG5TkJxJBiE=; b=M1xKuocbL7MIW7U/uOUWMDNlKibu18Dh8E/wMbqklHRA+LOS8vCPf4twi2lcFBPfOM o0Ibj/txRQIZYxlqa6Ki457WL3RbSoY0RQK0n2nuzL2N7TXEI/2m4EAXTan13OSgKbWn rUhKDH23Wwnc6DseEJ5005vj4NGlzTioYjcHiTUAHInumIxZWSW9/K0QGB4qu6RF2EMn +LKm+/Yq+GB91B0zsKo7JOeVT5Vjm3FDp47GMmRJuMo+abmKcTDyYRPhun8RwESe8pwd cOCbFfhbSBQlVCyyTcVZhFR35kA0oBoZs3Qf5IQUFE8T5Z7oqQCGby+uov2xOAfeCF0v GLMQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Az0Twaeh; 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 d75a77b69052e-4465148a11dsi71407751cf.242.2024.06.30.19.51.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jun 2024 19:51:48 -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=Az0Twaeh; 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 1sO78V-0002xn-1R; Sun, 30 Jun 2024 22:51:23 -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 1sO78T-0002tw-An for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:21 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sO78R-0008Vn-EK for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:21 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-7066f68e22cso1474730b3a.2 for ; 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=1719802278; x=1720407078; 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=mPMDVI+D07uyiyyk8Iq5xR3y1Ye6RQN5Bs9ydJnDyA0=; b=Az0Twaeh5w2XSbykktmKCOSS43tx9AFv10//13yy3pktqNsOUwUDGE/4iygAuK5+gu CDroVflXbZzxsni9I//OoEJANSS9ndItebNECqLM+OcSzCrk1E4NQRUznwwPeR0ZNld4 0Lt6Sei0iyNy7hcwEr2Ia6/HF4C5RKitxsihM6DI/N6GfJJZGIW/KLBlNybGA6iKvPEI +siVbGDdDS9Yx+1BQL/O5oQYMOY2/ossUoF4p0Kp0ZgV73cy7vewwE/wJTPA0VPuFa2M ugsnKH+cZbrxJxVe08YN23AdUpKB/ygt4HHG3zISJaayJdJ6HVDpOYS5fW7LEumCloHb EOxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719802278; x=1720407078; 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=mPMDVI+D07uyiyyk8Iq5xR3y1Ye6RQN5Bs9ydJnDyA0=; b=V9mIqYOJGzG/Fc6LLkOGqCwHjiTct1JbFbMOLQH4D3JKFY+EAD4oJQD3lmmqr6Aktp LPquhBNKmOhD9I+Bf9ogOeMgZNB71qkaXs0RHWrY8XGJFrvsuQE2QkKVs61CTVjEZSvm HNROP4uSCYABuKb9VTGI75u4Ykq6fVpXjtfwClmJeVZixuI78BN2hMEZQOPQXgiiJsQo 08H0Se5IlANvZ3PkpRz68PHVc0Dl7NvLMO8/r5fxAEo/wUX61zF0bFZ6CIE2MuGQJclq qa5eMO03/GRnhk5GRT0j3kEMOt6PSqCYjvk8117k3k+GJ4Nc5D6qbf2kSkWqekO7zY1I tr2Q== X-Gm-Message-State: AOJu0YxA4inUURr14lorGRrrXIUKPbS8HvCrBtmTEurKtbFG8IrKsrA2 xgpVkqK4yjJBKdwTPebO8U3DTjiSs6kzD3OI+fi85Bi1VDZDjYZDhSeG8Qrkgs78AxZv7qfJdMh F X-Received: by 2002:a05:6a20:7fa9:b0:1bd:253e:28e with SMTP id adf61e73a8af0-1bef61398b1mr3590112637.16.1719802277424; Sun, 30 Jun 2024 19:51:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 19:51:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com Subject: [PATCH 1/5] target/i386: Tidy cc_op_str usage Date: Sun, 30 Jun 2024 19:51:11 -0700 Message-Id: <20240701025115.1265117-2-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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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 Make const. Use the read-only strings directly; do not copy them into an on-stack buffer with snprintf. Allow for holes in the cc_op_str array, now present with CC_OP_POPCNT. Fixes: 460231ad369 ("target/i386: give CC_OP_POPCNT low bits corresponding to MO_TL") Signed-off-by: Richard Henderson --- target/i386/cpu-dump.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu-dump.c b/target/i386/cpu-dump.c index 3bb8e44091..dc6723aede 100644 --- a/target/i386/cpu-dump.c +++ b/target/i386/cpu-dump.c @@ -27,7 +27,7 @@ /***********************************************************/ /* x86 debug */ -static const char *cc_op_str[CC_OP_NB] = { +static const char * const cc_op_str[] = { [CC_OP_DYNAMIC] = "DYNAMIC", [CC_OP_EFLAGS] = "EFLAGS", @@ -347,7 +347,6 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags) X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; int eflags, i, nb; - char cc_op_name[32]; static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" }; eflags = cpu_compute_eflags(env); @@ -456,10 +455,16 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags) env->dr[6], env->dr[7]); } if (flags & CPU_DUMP_CCOP) { - if ((unsigned)env->cc_op < CC_OP_NB) - snprintf(cc_op_name, sizeof(cc_op_name), "%s", cc_op_str[env->cc_op]); - else - snprintf(cc_op_name, sizeof(cc_op_name), "[%d]", env->cc_op); + const char *cc_op_name = NULL; + char cc_op_buf[32]; + + if ((unsigned)env->cc_op < ARRAY_SIZE(cc_op_str)) { + cc_op_name = cc_op_str[env->cc_op]; + } + if (cc_op_name == NULL) { + snprintf(cc_op_buf, sizeof(cc_op_buf), "[%d]", env->cc_op); + cc_op_name = cc_op_buf; + } #ifdef TARGET_X86_64 if (env->hflags & HF_CS64_MASK) { qemu_fprintf(f, "CCS=%016" PRIx64 " CCD=%016" PRIx64 " CCO=%s\n", 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); } From patchwork Mon Jul 1 02:51:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 808825 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1376493wrr; Sun, 30 Jun 2024 19:52:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJ1z+gC6UaQEuPNN3MUC4L5p1OkQc2mEPObROzDAD96iTZD+UnXvCIsKTMiSxbk10A39SDz0wAo9jDe5Cm3yPt X-Google-Smtp-Source: AGHT+IFXfbVifX3NZzRZPQii5wL0m2XDp2jVSbVL6aRsjYFGch6QkISLq0zwbqb6AvQMQrji0/c/ X-Received: by 2002:a05:620a:2449:b0:795:5de4:6625 with SMTP id af79cd13be357-79d7b721042mr851779585a.5.1719802343792; Sun, 30 Jun 2024 19:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719802343; cv=none; d=google.com; s=arc-20160816; b=rXi/cE/ERxJy4t4A3ajfZMW9h3g0EBHzfYcVsZYT4oambCcoS0RA3WQSXRfivdA7hU yFgng1wy9+r+rcTmJYZDt16bQIBc9zSrj2kBnG5W2JxsKRvJkmcHtFsGtCzHRmz0RDej j9uAKIWrOPGb/b7n8mf2Zvm/WEbFgLpjdsXUXe0yRuQCRwV7M5nEo9l63djp9rwvX6eQ xGFldoVaaVRiilA9WzPXjrnjoOcR4yJKT9j32OxBRvQWLYB4qbhB/EnGMOIRdtwLr1Yp QhNjIvP0qp8q/qvprpIl+DeWK88pqJmBNIaw4FyLShlcmAG8KCuOjxC3tBxSH+NKtuh5 j7bw== 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=+mPvMUbmRUW5qOg66PJMTfVpv43K7IU1VZRf6V6fQ1Q=; fh=3mEp7FusppN5Drq2PN08R8D/9xXM9YdbtG5TkJxJBiE=; b=vSfNjqLi4UFeCR3AX3AKCBdeGdGuKHKy/GnGahCya5SUGi68FEXzoJZXENBF3+J3Xy Wdhi5NFysEq97xQSKTBlPrsRz+4AdABUYfA31wEg3364L4H2oiGgpsrPhQGTaj0rTUDC 0nxpUE+Sq6hy+ODnYH380cO1YH9k032r6tsdXxjDfGgwlMJ4luSlHQobK9vjAv/gqOje OMtLo4aRcKg32obbsSQ+oz9EAWI0NQGFXbjOQsIOo1PaghuLPz3+lxbvLUFtFz6BkEIW 6csPRL6ezEdLJVMu95QSJbmppAssTOFGziFBt8sRPwwk8lWo4gBXZv+rTe5lFkept4W/ iq0A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="V5/JjILY"; 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 af79cd13be357-79d69339c74si674880585a.619.2024.06.30.19.52.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jun 2024 19:52:23 -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="V5/JjILY"; 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 1sO78X-00030h-Ac; Sun, 30 Jun 2024 22:51: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 1sO78U-0002xL-Qg for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:22 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sO78S-00007m-TZ for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:22 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2c84df0e2f4so1601400a91.1 for ; Sun, 30 Jun 2024 19:51:20 -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=+mPvMUbmRUW5qOg66PJMTfVpv43K7IU1VZRf6V6fQ1Q=; b=V5/JjILYl8P0sxw3n2cUbZh/sMn5dztL6nI3t28zgPpENiEMoeQlsj9yaQ2OjshKoi WJdZhW1WDprayRfjLCXoduGM5wweEafs+aZFS5D42nEGxUA5Ti4Of6FNLNdL2/V7qQWl mag/oO0c7IGP+BQS9TKc9pBlpxBe7y1LKaiEL4B1M8ykI0P6Ee4nPNzQ6FRzhzCETqow D+d500UDnQja70WlBwYrGxmJtZ2pcdrcGLL9gqC0B1R2cS2Spzee0qw1ICcYQRUyG+Tn 89xF6c0QoMiq3tKGilB8W3mo0POR0Ob2c2+LP5sJNpocJmoifO7OaBab2jW53hPcfrjC sVlQ== 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=+mPvMUbmRUW5qOg66PJMTfVpv43K7IU1VZRf6V6fQ1Q=; b=TrUzLUe6EFrngqAUweg7jwOOdOjxE6DbjzUfJbcIGAwQj54CZpbWMeco3trXRRBWax njrJEwrga/wGYcFrXmT+eoT4bIIn62/8q+RNeh/wByLH4l37tjaNqt4ARPWjX0pld6Dz 9fFURDrMrEQKYaF1SMC4zdbImTcKhOXpi28jy4txJTmGq0E48Pz2aSg8bEjRP0NYpGtl Qz1HSVb7bQRdbbt64OWzRzRx2y49LQ+RTVHcnB51qy9gU8/IdFhqJ0CMmH0mq0Q9bGBo BTyemmX1IgP0OkmMYcGP+9fMj28wFzBi3UMHLURWZMx54Xf/eQAWWA33l4Z3k/gKFgZo wmMw== X-Gm-Message-State: AOJu0Yz63QAjsm+nyk8GwosIR+9efDEabDBXXCPIfgGu+5jQUxj5yROg XzpXxXbNDutDvlV4gz/bMfS0axrnrM9a1nSwPrb0UVcpnoaTC9pKgloGs7ZdxP7gSFr/OElRLXH 3 X-Received: by 2002:a17:90a:5b0e:b0:2c8:946b:eea2 with SMTP id 98e67ed59e1d1-2c93d1b9307mr7041641a91.7.1719802279273; 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.18 (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 3/5] target/i386: Rearrange CCOp Date: Sun, 30 Jun 2024 19:51:13 -0700 Message-Id: <20240701025115.1265117-4-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::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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 Define CC_OP_{FIRST,LAST}_BWLQ. Remove CC_OP_NB. Give the first few enumerators explicit integer constants. Move CC_OP_POPCNT up in the enumeration; remove unused CC_OP_POPCNT*__ placeholders. Align the BWLQ enumerators. This will be used to simplify ((op - CC_OP_*B) & 3). Signed-off-by: Richard Henderson --- target/i386/cpu.h | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 29daf37048..df4272fdae 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1270,14 +1270,27 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, * are only needed for conditional branches. */ typedef enum { - CC_OP_DYNAMIC, /* must use dynamic code to get cc_op */ - CC_OP_EFLAGS, /* all cc are explicitly computed, CC_SRC = flags */ - CC_OP_ADCX, /* CC_DST = C, CC_SRC = rest. */ - CC_OP_ADOX, /* CC_SRC2 = O, CC_SRC = rest. */ - CC_OP_ADCOX, /* CC_DST = C, CC_SRC2 = O, CC_SRC = rest. */ - CC_OP_CLR, /* Z and P set, all other flags clear. */ + CC_OP_DYNAMIC = 0, /* must use dynamic code to get cc_op */ + CC_OP_EFLAGS = 1, /* all cc are explicitly computed, CC_SRC = flags */ + CC_OP_ADCX = 2, /* CC_DST = C, CC_SRC = rest. */ + CC_OP_ADOX = 3, /* CC_SRC2 = O, CC_SRC = rest. */ + CC_OP_ADCOX = 4, /* CC_DST = C, CC_SRC2 = O, CC_SRC = rest. */ + CC_OP_CLR = 5, /* Z and P set, all other flags clear. */ - CC_OP_MULB, /* modify all flags, C, O = (CC_SRC != 0) */ + /* + * Z via CC_DST, all other flags clear. + * Treat CC_OP_POPCNT like the other BWLQ ops in making the low bits + * equal MO_TL; this gives a value of either 6 or 7. + */ +#ifdef TARGET_X86_64 + CC_OP_POPCNT = 7, +#else + CC_OP_POPCNT = 6, +#endif + +#define CC_OP_FIRST_BWLQ CC_OP_POPCNT + + CC_OP_MULB = 8, /* modify all flags, C, O = (CC_SRC != 0) */ CC_OP_MULW, CC_OP_MULL, CC_OP_MULQ, @@ -1332,20 +1345,11 @@ typedef enum { CC_OP_BMILGL, CC_OP_BMILGQ, - /* - * Note that only CC_OP_POPCNT (i.e. the one with MO_TL size) - * is used or implemented, because the translation needs - * to zero-extend CC_DST anyway. - */ - CC_OP_POPCNTB__, /* Z via CC_DST, all other flags clear. */ - CC_OP_POPCNTW__, - CC_OP_POPCNTL__, - CC_OP_POPCNTQ__, - CC_OP_POPCNT = sizeof(target_ulong) == 8 ? CC_OP_POPCNTQ__ : CC_OP_POPCNTL__, - - CC_OP_NB, +#define CC_OP_LAST_BWLQ CC_OP_BMILGQ } CCOp; -QEMU_BUILD_BUG_ON(CC_OP_NB >= 128); + +/* See X86DecodedInsn.cc_op, using int8_t. */ +QEMU_BUILD_BUG_ON(CC_OP_LAST_BWLQ > INT8_MAX); typedef struct SegmentCache { uint32_t selector; From patchwork Mon Jul 1 02:51:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 808821 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1376364wrr; Sun, 30 Jun 2024 19:51:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXDlmpRemzE4POVn/tD7F4PBBqMTeRZ1owAwWBSB2Z44SkObe8gaDi9oUqycRfzb7UuLQWmnflhKRCNiD+g2Qrk X-Google-Smtp-Source: AGHT+IHo/h6yzIN73QYQ/RCuQiIJURsmkN8sEx41GWTwqT9Cy3OAqNHuJTQbJaz82QMMu1cS9V4v X-Received: by 2002:a05:6214:1d06:b0:6b0:7d80:38b2 with SMTP id 6a1803df08f44-6b5b71bf1fcmr43460406d6.64.1719802305794; Sun, 30 Jun 2024 19:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719802305; cv=none; d=google.com; s=arc-20160816; b=gNaHfm0WWTbmRjabRLZEFpWYn7f3dMPTT9j0/Bty+BajSb5mU6KdIqLhkuaB62PpTD qCXxZpkwOu8vj9rpypIHOqRiExamPPBUGdVN6dimfQvyCkgJvbHyb0Ubww32KAlfiMfh ZZ+pQcpH9UL1VT7XbYFUXzF5nFp36Fh0EophVMzrmVn0tTyIMQ6Y2wFR9Z6/4GSX15jM fvgEMYCRewGxPJsKDwLxbCeb/ynchwWp2ZByZ0YvYnNe0hKjINxOXamRw7+6bKHYkDb7 mMwjhTdYdqlS4vuVZFbVN2BMM9dbWVQqU/fBnXITaSfNQLm5Nb6AIVrTJg96Ig4KySwx tokQ== 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=M3N6rPlpvzYKdcGfQuTrjYcbyNAlpYXYp9ucQoujl0c=; fh=3mEp7FusppN5Drq2PN08R8D/9xXM9YdbtG5TkJxJBiE=; b=L95qFwPlAic6hXpYYK7THfmicOc2t+4EuxyTQ9Ms9kSXeWeLwM5wg/SqXu7MReLlIU yBRLHFrBBd+rMdqfwd18MCu8U3UG+bmnSd6UBShikmY0RtFc8vsvkQb5cJKJrzVPxrcK 5eADNH1SYkwLZtHwSLVAoOUZaXcCvVTnIbUu/emBvOPyh0TqYwcTxYHeVMKcjBvU+ulv SglPYhXrSiI5uV8wg6i2E76O0M+S4iUn0sobHvKEqPfn3J+bLJ1wdUovUB32eFfYObM+ 8zSR4KNyvjNN8hQF/wo0rq9YohfsaTKi/SLenFaSXAwSs9rzLg7W/TQLyUs5WsQYqvBk iseQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MBMM8ZAQ; 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-6b59e5ada0fsi73156106d6.261.2024.06.30.19.51.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jun 2024 19:51: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=MBMM8ZAQ; 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 1sO78W-000304-6i; Sun, 30 Jun 2024 22:51: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 1sO78V-0002yS-7w for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:23 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sO78T-0000DQ-LB for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:22 -0400 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2c8e7553c9eso1794296a91.3 for ; Sun, 30 Jun 2024 19:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719802280; x=1720407080; 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=M3N6rPlpvzYKdcGfQuTrjYcbyNAlpYXYp9ucQoujl0c=; b=MBMM8ZAQ/LynmXoslz7vX4zIJjv7/3x/6x4CHIgo1bYTDREuXGwTVqftSDsBLck1BS 4jIqrL/fsVsaKUK6T4r6vmko274QBcSvG4/T0keJPdNv5JcSdZwtlCm0zFesTG7GymDT nydsCGLE9ce/Pu1HQgZqaNBhSAGzk08H/6X9zQnZ6W/HKEt5OjzhbClqi0InB8cfCkaM O97HBXhuljL9dcymQMSOpPfXpf0EpvoWwjYt8Ydm1ML3gyxmtZe+gcvUzeEkubnGt2p4 8W6E/6eTUuNsnvpzHAqsNYYmLX0puJ2/bEtQqUEtCyd6XPhCCVj88+G+mhVbNYWYhaad JM8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719802280; x=1720407080; 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=M3N6rPlpvzYKdcGfQuTrjYcbyNAlpYXYp9ucQoujl0c=; b=AjC4VBDKq3kwOtbra5Jgntv3I3DY9n1bBNSaftofqFDd2rJgdMgirnFtK2lukHVdEs TZSkz077aeG+LDf3QHK413Shjn+mIk+qlJMc99DoMLcn3S3sRsu4ot30hlbL85FRj6aw 8vIA8nloKHJnOXiEZj/QSgnBaWvgECgcGH+dGXrSPbstogf2QrZfLpYYwF+z064d77JX RBIlirRFxqY6yHibT53dH2cx93+H+6uYXHEeNzvvS7n1ABf1o8CYhWx7luFuV8TKNUAy 2aGpZ2rrv35AbBshAP49Fz5Dokn0PpTVsJclEWNWUPZHHTLN4lhg2O+bmfex3Gt428NO iLMg== X-Gm-Message-State: AOJu0YzRfEYe3l+WfNhq1YuAxYulYiWNlCZJQNUum1sHMkf4l8HjDNdL vTPKwPiGwOC6hfZd+CA7Lhi6BB2Ej5Ym3wbLSl3q8/nLOODMCuQJ58SmvrS8+CQUleKB+ggRtSF z X-Received: by 2002:a17:90a:c084:b0:2c7:c6a1:42c9 with SMTP id 98e67ed59e1d1-2c93d6f22ffmr3648624a91.10.1719802280206; Sun, 30 Jun 2024 19:51:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 19:51:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com Subject: [PATCH 4/5] target/i386: Remove default in cc_op_live Date: Sun, 30 Jun 2024 19:51:14 -0700 Message-Id: <20240701025115.1265117-5-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::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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 Now that CC_OP_NB is gone, push the assert after the switch. This will allow -Wswitch to diagnose missing entries. Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index e5a8aaf793..e675afca47 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -318,9 +318,8 @@ static uint8_t cc_op_live(CCOp op) 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(); } + g_assert_not_reached(); } static void set_cc_op_1(DisasContext *s, CCOp op, bool dirty) From patchwork Mon Jul 1 02:51:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 808823 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1376406wrr; Sun, 30 Jun 2024 19:51:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVoA6k2DvR6vt7DJkZvxKCq8EqTX2ufHLptCV2JxLaWoMXQuAoSK7fo+IcWNrJ952vMpdGecNpJML9MpZ1ZMLDK X-Google-Smtp-Source: AGHT+IG1ND5KG4DLcU96oSeEhOlHv4zGfXnTdhmygtm8YQ969sQgQy4uE4o6bPml9qjCZGY2avoC X-Received: by 2002:a05:622a:138d:b0:446:573f:b34f with SMTP id d75a77b69052e-44662dd3d83mr50664801cf.21.1719802317898; Sun, 30 Jun 2024 19:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719802317; cv=none; d=google.com; s=arc-20160816; b=pvrzShpzX71QhUf+4LNYb6zZ828uBtkaCTCa24MG3nkDIcEYNioI1xVdroGs1RvrYM VgXPJK7awRuHbdO8ds40iziQnRKiXjE2OwfMT4LaGPAeLVTorrfqeMfLmiMni4DgVwsI a97gcuId5bZL0rqYrSLWoHzHgildTW/Jbhveiq6lzwhUVX74qZ5IJRcjfpb1IttYVOih Raa53AvxNj1IS6vZYhzVGO3S1yzAtTARrx/VWdLlB4vcBFYMfhHRl82GTQfkkwrYRIE9 jqmrS8hi1liH107Xs0zsJ1siBQab6dOU7EDeXpt/eBoSI0t0XH+wXDfWfeNHXpSUtRkn f7sA== 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=v8ctItCGfyeAkHxXU4PbxRnvrKAFyRywgfWFR/Aj32s=; fh=3mEp7FusppN5Drq2PN08R8D/9xXM9YdbtG5TkJxJBiE=; b=mDFReIX8yFy0TIRAtcWOA/QcBBIOmoooNcHqyU91+QCw9FqEITN8Sc2juv5WeJjYoz 3eAFJYFOPqtj7FdSKlNkO5i39rH3Zp5k97dkXLZ9c/rBd9BToZxy9hiHkLAV+zA08g6h 7a6uRz0yDaD3iC66eOCOxIpkm8EiH1qjjKFYNQTPxUa2H3Ci+Vc29KPMAwaMO4aGgTq4 VbouDDFY9Oj7o9Wte81yl6xByAVtbeCUP1zIRbzwvEo31q9+6y5zVFL9BOzAQbFSen0q wJbuH3qhyCR5CLqVNdg9QfadxeS7Pwsr5r/ksRTS+IBVMYv+qzUyReJ/m8BmJpmtaiVX QU6Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ema0Nc/a"; 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 d75a77b69052e-4465149f81csi71054371cf.397.2024.06.30.19.51.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 30 Jun 2024 19:51:57 -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="ema0Nc/a"; 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 1sO78Y-00031H-Qq; 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 1sO78W-00030C-Bq for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:24 -0400 Received: from mail-oo1-xc33.google.com ([2607:f8b0:4864:20::c33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sO78U-0000Gi-D2 for qemu-devel@nongnu.org; Sun, 30 Jun 2024 22:51:24 -0400 Received: by mail-oo1-xc33.google.com with SMTP id 006d021491bc7-5ba33b08550so1282289eaf.2 for ; Sun, 30 Jun 2024 19:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719802281; x=1720407081; 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=v8ctItCGfyeAkHxXU4PbxRnvrKAFyRywgfWFR/Aj32s=; b=ema0Nc/adOPDBVBO3usYdvf7a3LvHZwU6gPs4LvuvCCrRbStuyDVo1ET9Zv+MpW8sH JTnIcqixzOe/fDyrqH5wnWhkQ9HWd4qi69vs6v2ckCgrbKSoImrnalJhh+wWzpvmykRX IvzMRRPtnmA+dy87kxPL0B29oP6yFyAxcnGcOO9ifU8vQEKHjdcTcp+EA8IXBeB9rp8J lXQwWx+6QoanMXlh1FDlKTYdNcvw6ayDCt/myBxFW8NegvMztR+JmgWrg1+dLY4pbgrW h57yBnOGt6JdNTyTpzYy9dYcgnNB1XJ1tvrMCE1jkwMrGMTbfd5yx0ZLnvdh1nNITBrS TdRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719802281; x=1720407081; 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=v8ctItCGfyeAkHxXU4PbxRnvrKAFyRywgfWFR/Aj32s=; b=LJZuI4dMSeHPV+SFH3uRUFK85tii12eBz4kb9dkfMqaGEMdBFGp9zrbkhlQ8Kc5JhB kA0f6h4iVUr+8x8ZWxtcylPUJ+ldMoIxHt1tyAhbcfL+P5N9ONlmkVE/pFwnQsHiB1e2 wUAoaO/zZAFzsc/FFwhjlYHew+9q2+0iLKZVClotTMKQrAj4hHKTyBABSNugseDfGkq8 JTCTc6cmHVbiYgXfneIABJxsahoFesSC/ck0PfVIu9PQiKhAFyEg/rGoHiypPQhp45Ko UAoBdE9O5rhYVEzCDTj2ZoSOj2dVQrwXJNN3iiFcLnilGsq9hXL2PC51TzZd1OAYvItm 0XWA== X-Gm-Message-State: AOJu0YyHdu2omGRD3Q2aa4lc2Y4xuIZec0CUQYdt5S6htX6rMeV8hz82 nGIsLM0FoVtmhNT9obCmBTqPtMZnbB0DC5LEly3NqDZTv5MSVYF7ePT4UbeHAzgYL5cXawgDhAI k X-Received: by 2002:a05:6358:7e16:b0:19f:45a6:4965 with SMTP id e5c5f4694b2df-1a6acccd74emr502455955d.7.1719802280921; Sun, 30 Jun 2024 19:51:20 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 19:51:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com Subject: [PATCH 5/5] target/i386: Introduce cc_op_size Date: Sun, 30 Jun 2024 19:51:15 -0700 Message-Id: <20240701025115.1265117-6-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::c33; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc33.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 Replace arithmetic on cc_op with a helper function. Assert that the op has a size and that it is valid for the configuration. Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 29 ++++++++++++++++++----------- target/i386/tcg/emit.c.inc | 3 ++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index e675afca47..e98bed0805 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -322,6 +322,16 @@ static uint8_t cc_op_live(CCOp op) g_assert_not_reached(); } +static MemOp cc_op_size(CCOp op) +{ + MemOp size = op & 3; + + assert(op >= CC_OP_FIRST_BWLQ && op <= CC_OP_LAST_BWLQ); + assert(size <= MO_TL); + + return size; +} + static void set_cc_op_1(DisasContext *s, CCOp op, bool dirty) { int dead; @@ -884,7 +894,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) switch (s->cc_op) { case CC_OP_SUBB ... CC_OP_SUBQ: /* (DATA_TYPE)CC_SRCT < (DATA_TYPE)CC_SRC */ - size = s->cc_op - CC_OP_SUBB; + size = cc_op_size(s->cc_op); gen_ext_tl(s->cc_srcT, s->cc_srcT, size, false); gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); return (CCPrepare) { .cond = TCG_COND_LTU, .reg = s->cc_srcT, @@ -892,7 +902,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) case CC_OP_ADDB ... CC_OP_ADDQ: /* (DATA_TYPE)CC_DST < (DATA_TYPE)CC_SRC */ - size = s->cc_op - CC_OP_ADDB; + size = cc_op_size(s->cc_op); gen_ext_tl(cpu_cc_dst, cpu_cc_dst, size, false); gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); return (CCPrepare) { .cond = TCG_COND_LTU, .reg = cpu_cc_dst, @@ -910,7 +920,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) case CC_OP_SHLB ... CC_OP_SHLQ: /* (CC_SRC >> (DATA_BITS - 1)) & 1 */ - size = s->cc_op - CC_OP_SHLB; + size = cc_op_size(s->cc_op); return gen_prepare_sign_nz(cpu_cc_src, size); case CC_OP_MULB ... CC_OP_MULQ: @@ -918,7 +928,7 @@ static CCPrepare gen_prepare_eflags_c(DisasContext *s, TCGv reg) .reg = cpu_cc_src }; case CC_OP_BMILGB ... CC_OP_BMILGQ: - size = s->cc_op - CC_OP_BMILGB; + size = cc_op_size(s->cc_op); gen_ext_tl(cpu_cc_src, cpu_cc_src, size, false); return (CCPrepare) { .cond = TCG_COND_EQ, .reg = cpu_cc_src }; @@ -972,10 +982,7 @@ static CCPrepare gen_prepare_eflags_s(DisasContext *s, TCGv reg) case CC_OP_POPCNT: return (CCPrepare) { .cond = TCG_COND_NEVER }; default: - { - MemOp size = (s->cc_op - CC_OP_ADDB) & 3; - return gen_prepare_sign_nz(cpu_cc_dst, size); - } + return gen_prepare_sign_nz(cpu_cc_dst, cc_op_size(s->cc_op)); } } @@ -1016,7 +1023,7 @@ static CCPrepare gen_prepare_eflags_z(DisasContext *s, TCGv reg) return (CCPrepare) { .cond = TCG_COND_ALWAYS }; default: { - MemOp size = (s->cc_op - CC_OP_ADDB) & 3; + MemOp size = cc_op_size(s->cc_op); if (size == MO_TL) { return (CCPrepare) { .cond = TCG_COND_EQ, .reg = cpu_cc_dst }; } else { @@ -1042,7 +1049,7 @@ static CCPrepare gen_prepare_cc(DisasContext *s, int b, TCGv reg) switch (s->cc_op) { case CC_OP_SUBB ... CC_OP_SUBQ: /* We optimize relational operators for the cmp/jcc case. */ - size = s->cc_op - CC_OP_SUBB; + size = cc_op_size(s->cc_op); switch (jcc_op) { case JCC_BE: gen_ext_tl(s->cc_srcT, s->cc_srcT, size, false); @@ -3176,7 +3183,7 @@ static void disas_insn_old(DisasContext *s, CPUState *cpu, int b) CC_DST alone, setting CC_SRC, and using a CC_OP_SAR of the same width. */ tcg_gen_mov_tl(cpu_cc_src, s->tmp4); - set_cc_op(s, ((s->cc_op - CC_OP_MULB) & 3) + CC_OP_SARB); + set_cc_op(s, CC_OP_SARB + cc_op_size(s->cc_op)); break; default: /* Otherwise, generate EFLAGS and replace the C bit. */ diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc index 38b399783e..e9d5d196ce 100644 --- a/target/i386/tcg/emit.c.inc +++ b/target/i386/tcg/emit.c.inc @@ -3106,7 +3106,8 @@ static bool gen_eflags_adcox(DisasContext *s, X86DecodedInsn *decode, bool want_ * bit, we might as well fish CF out of EFLAGS and save a shift. */ if (want_carry && (!need_flags || s->cc_op == CC_OP_SHLB + MO_TL)) { - tcg_gen_shri_tl(decode->cc_dst, cpu_cc_src, (8 << (s->cc_op - CC_OP_SHLB)) - 1); + MemOp size = cc_op_size(s->cc_op); + tcg_gen_shri_tl(decode->cc_dst, cpu_cc_src, (8 << size) - 1); got_cf = true; } gen_mov_eflags(s, decode->cc_src);