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;