From patchwork Mon Apr 24 05:40:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 676499 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp1985225wrs; Sun, 23 Apr 2023 22:45:20 -0700 (PDT) X-Google-Smtp-Source: AKy350YkC5AhwCiLRCfpJ+f56kFU8ZIyVEN/umlL6FDcNnbZhWxL5BikdnxXeAmpILBnf73AR9Cm X-Received: by 2002:a05:622a:1a13:b0:3e6:45e7:f170 with SMTP id f19-20020a05622a1a1300b003e645e7f170mr23729439qtb.50.1682315120783; Sun, 23 Apr 2023 22:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682315120; cv=none; d=google.com; s=arc-20160816; b=M23tnKqxgCqlIUHsyN1KchxzDj1RaurFWturwrbeZyrgWAGaxHHcHu1o9LaE/HF6+T 7mCB5g4hk8Wq8Ug92Z8ghWgUpvt5ToMwszUTvOFegXrLZsH3oSuN/2j3fNZC2KD4V9iO tJ7GqAS5+WFcTRTd56WCRyM2AGc18CqXuN+rHFTgBxHIgRXKqVur32YOzOXuWnQx37sT kTI0mfvn7MvFUGSgKPMdByK4T44j7ug/CeBxC+ifQyx+kHDgauOQCLNobp+IBNqJzXAu pDXyvuioRV3bN2ik8QBcVlQQne1xzpB0dkUh0vvxy5MRd1sVPiszm4gwLwMVl5Jx7DgX e2pg== 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=IJnzORJY4nHB2qHgbe1wyr1FPPmEsXDzn2QzLUICVbI=; b=vlSy60iZCCrSce/2LdRswbeyvJfE2vyxXkFmyWQZuVxyFqzv9OLtjHQhf5ks1V9CSv TPystxP4kO3UnuaVvkHD1LDKlMMEexaka+s6UDfh9lC3ecyyzq7tVlQamT94nayT9kfS 1tW1XS0UEk/aa93m0fkBUmZ1bjqn9v1nU8PlIYI5GVhIonL4R1dmExce1dfNV55wmqpb e1dy7Of2QoB3itMBXOU5DpCZos8HxAFqlUluRkfzgsZYAhpGzXygYPl0x2AQWTRqn04D rKfVUl47f6dSonsf3npMpm2J09uRRFaeWMhqBaswzEID2WbYw5oqDRFaQJRYojXGTM0l 2fnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="wsrYLo/z"; 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 s13-20020a05622a018d00b003df1bfceca9si1235820qtw.24.2023.04.23.22.45.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Apr 2023 22:45:20 -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="wsrYLo/z"; 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 1pqoxL-0005Wd-Qf; Mon, 24 Apr 2023 01:41:43 -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 1pqox6-0005MH-E1 for qemu-devel@nongnu.org; Mon, 24 Apr 2023 01:41:29 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqowt-0004Gs-1c for qemu-devel@nongnu.org; Mon, 24 Apr 2023 01:41:28 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-2f4c431f69cso2315045f8f.0 for ; Sun, 23 Apr 2023 22:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682314871; x=1684906871; 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=IJnzORJY4nHB2qHgbe1wyr1FPPmEsXDzn2QzLUICVbI=; b=wsrYLo/zEiJ1a2FC+B4pAjorUgO1McKdllwK3A6Rrxz5alsIwaKMGSVQxjZPbSxlrc 1GcnzLeWh2wXA1WCBterba4Bz5K/9jeBG6R0wy+aaegGwV/f/I1Kxz3y53vsBVyY0ZOd YYPJw/urf3rwLn81rTLuO340cBPCkaEXLOoWblgnccdaAOZPvDlnN1S1yc7HHEXpnSvM df6JCt/SYGTueFDS9IMWUmNe/UaXhE6DZwZXhrJ3FW/6f9dUeH3u3nNMoSf+LQUW5Xvc A4hCBcwfpIjKI7/1MCoiUy7QQLN58UX1L+0WquD8vkuk6ppUv/UPh/aTxsOv58vREtZQ 99lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682314871; x=1684906871; 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=IJnzORJY4nHB2qHgbe1wyr1FPPmEsXDzn2QzLUICVbI=; b=LNjuRBa8v5Q1eEZsUFxuTL/XEnKRK6LnajQHaHUlz2DLswg4iU5B45O6yEcEZZy1ai P77MpZBy/caLQDydPzwBrOnBHTcwOhXX/f87Xf0XL28JklEZta70rvBpx7d9ywUZscB0 h2TT0H4X6XGMytTtY3fMRl7g+w2C7DaYRC6VzRfS3yGyjZrjfZYJp2Z5+nN1MC4rKqn6 2ZG9lQFtVdV0NTaP2Kr3RPrblZ8qXCyW7uAoBHinUTQqmyfAAa4iUXiovxssrBxrNovu hKTOFX9QGojEjoBIQ5/WkE095GEK5ASJF8KdJLW+Lpq0Mi+1FpNMPsDv742BQ+H9VBsq H0EQ== X-Gm-Message-State: AAQBX9dp837jXOYl/91jqbavJe0Rwz7KA4uHzVKZTFoV9Pynx/c7skEM DNop8lOnGak+y24zbgPVi2JmQj9y/L2QtqCyxL0YyA== X-Received: by 2002:adf:fa85:0:b0:2fa:6929:eb81 with SMTP id h5-20020adffa85000000b002fa6929eb81mr7889175wrr.31.1682314871540; Sun, 23 Apr 2023 22:41:11 -0700 (PDT) Received: from stoup.c.hoisthospitality.com (cust-west-loneq8-46-193-226-34.wb.wifirst.net. [46.193.226.34]) by smtp.gmail.com with ESMTPSA id j22-20020a5d6e56000000b002fbb285b01fsm9997852wrz.25.2023.04.23.22.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Apr 2023 22:41:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, git@xen0n.name, jiaxun.yang@flygoat.com, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 09/57] tcg/i386: Introduce tcg_out_testi Date: Mon, 24 Apr 2023 06:40:17 +0100 Message-Id: <20230424054105.1579315-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424054105.1579315-1-richard.henderson@linaro.org> References: <20230424054105.1579315-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42a.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 Split out a helper for choosing testb vs testl. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.c.inc | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 7a02f79f1b..19625a7c75 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1753,6 +1753,23 @@ static void tcg_out_nopn(TCGContext *s, int n) tcg_out8(s, 0x90); } +/* Test register R vs immediate bits I, setting Z flag for EQ/NE. */ +static void __attribute__((unused)) +tcg_out_testi(TCGContext *s, TCGReg r, uint32_t i) +{ + /* + * This is used for testing alignment, so we can usually use testb. + * For i686, we have to use testl for %esi/%edi. + */ + if (i <= 0xff && (TCG_TARGET_REG_BITS == 64 || r < 4)) { + tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, r); + tcg_out8(s, i); + } else { + tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_TESTi, r); + tcg_out32(s, i); + } +} + typedef struct { TCGReg base; int index; @@ -2053,18 +2070,7 @@ static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrlo, unsigned a_mask = (1 << a_bits) - 1; TCGLabelQemuLdst *label; - /* - * We are expecting a_bits to max out at 7, so we can usually use testb. - * For i686, we have to use testl for %esi/%edi. - */ - if (a_mask <= 0xff && (TCG_TARGET_REG_BITS == 64 || addrlo < 4)) { - tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, addrlo); - tcg_out8(s, a_mask); - } else { - tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_TESTi, addrlo); - tcg_out32(s, a_mask); - } - + tcg_out_testi(s, addrlo, a_mask); /* jne slow_path */ tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0);