From patchwork Thu Feb 16 02:57:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 653973 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp119216wrr; Wed, 15 Feb 2023 19:01:05 -0800 (PST) X-Google-Smtp-Source: AK7set8ftteJ/1Kmp38wrFcQ2dBSNEklDFOxd11+jA8qUBefzc/zPqYmLgHly6JzIrJ0vrhQAwm6 X-Received: by 2002:ac8:5848:0:b0:3b6:3995:2ec2 with SMTP id h8-20020ac85848000000b003b639952ec2mr7899374qth.19.1676516465553; Wed, 15 Feb 2023 19:01:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676516465; cv=none; d=google.com; s=arc-20160816; b=vNdmHeHKN5ILmuIc8cmDaKL1P6xFcQwoLD49PnK+7u/dc+NfhR7sQA7pseN66JBq6n caxJjjNMT+qwzrLi7pfwxzTZB1Q05TDI3lEDwzr4IxRvUm4bT6GZiiP0jEeQFcVii5iG CWv5/zc5kKe3+XuDnfQNJCIvfuSPBZ8f+FMa1apsmwlop2R3OdCXAWUcnIl8i4xUEGh9 WaiADrhUsuYqFbThQiWRTa1eJT45WmVKHS9rM+stC4lrqkeoJxu/g9zKxaVUElTQgCPV n79lyYSyh0KPt6E4+N23ViKiC4TgWvBt4d0VV1vNbclsWMuS9w/tZlNvQGxoQTFpXBAz rohA== 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=afuwZcabde7LyQSxeaM/6PWqvilPqwbhg0UKCcmEKIk=; b=HxvLzNUZH5BodjoTn23PhbxKWm/2V0yQyRjE61cGoxFE1XDZWjKukLFhYmZSB8/Tti nneUT94tzBaLpqksOzLoyVw4dcUf3BHzZX5p1SrXOdON33PV9XPe7zUieHBbZojDiYMe zxUFA54wGTbD7SJ9L/YZmhgtanzmd9lHLJ8JiXw5hDbAIgY8yEHwZ2Gy2zdYrlDvZoyw XjXE41ltpErf5Ex9AMs1/5wPCPwP9u4dIkLsSR8PPRCZAxNGKWimom368DcLY4WXCnRi AG4KMWo2njgzDi/T/YL2gqnHvHRQlOfLrfYRKnGoZhC836f7sr5Z4dc+p6cdMBZDqzVv 0I3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AYiAC7SE; 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 y12-20020ac85f4c000000b003ba15b2d1f9si511104qta.604.2023.02.15.19.01.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Feb 2023 19:01:05 -0800 (PST) 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=AYiAC7SE; 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 1pSUTR-0003ZB-SU; Wed, 15 Feb 2023 21:58:17 -0500 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 1pSUTQ-0003Yj-3J for qemu-devel@nongnu.org; Wed, 15 Feb 2023 21:58:16 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSUTO-0005nd-CX for qemu-devel@nongnu.org; Wed, 15 Feb 2023 21:58:15 -0500 Received: by mail-pj1-x1032.google.com with SMTP id d2so546469pjd.5 for ; Wed, 15 Feb 2023 18:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=afuwZcabde7LyQSxeaM/6PWqvilPqwbhg0UKCcmEKIk=; b=AYiAC7SEBkMggu2by3pRAPL3RmibP0d/naZm0Lc+Rgh2sAaSpLRbR5+YbWZf5YWr9S S3tHp/bbnFJiFr/Hu6KIU/t931dqljsMmdY03QpoWCGs05u6SqA4FrD02c5aGmu+8lOA sByM4wcf0wKnJNmc0XGSaTuorLZbqzYVdfTkS7W6jsipTKLMHomm9g+H2B8P8uwabq7H psoH5hvMvwcLUYzzYHx0tdeAj/ZlCsMsl7eP5HhbB56P+qMdSdBNvyBgDvf04v6Hu36n 42NtjUoPZfeddH+6JJJQ1V1mj28CHqZxbskYSe+RkY69PEIVjcqR/GWNkjlyupJtZkBj 3COQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=afuwZcabde7LyQSxeaM/6PWqvilPqwbhg0UKCcmEKIk=; b=dqac0tz0DjsskuzcyX78UjRmOScv7uOmJKrpgGQHi1sfbfq//SxdnyVcrxAOfJp1xc 9lhJqsoRYPqklSqair55UhMK7RqdTfDm0KcShEYio5e1kyw9z8vBTAzJFe9XubQa6CFu +ZJjKGTJcL0ZCqxiAyMJafdru4Cf5MHh2TgAvDl0Ysl2VR4ZQDoQD3NaDJw/T+sNDfrS sXwCJpysZYjBQev8/koPFgbmb99DYT/kBNik7PZZQvg4QbeB7cLbfhCMdImv0v/dURbD JTJg3bR6f0q33K3IWFNtQj1va963biLvRndRhZE4upg23rGNIuyJmmcQ7sEMtuPSDkFd nxQg== X-Gm-Message-State: AO0yUKVcYAxOqXdm5Exyw11q0m+SzNQy+pHaQULjhc7PQbiIY8mRuQbA CpzMGHjxhSW41lxy02fSQzyM+SduBB7KiUOEAJo= X-Received: by 2002:a05:6a20:a1a5:b0:bc:ccea:a969 with SMTP id r37-20020a056a20a1a500b000bccceaa969mr3490714pzk.26.1676516293030; Wed, 15 Feb 2023 18:58:13 -0800 (PST) Received: from stoup.. (rrcs-74-87-59-234.west.biz.rr.com. [74.87.59.234]) by smtp.gmail.com with ESMTPSA id e14-20020a62aa0e000000b005a816b7c3e8sm89655pff.24.2023.02.15.18.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 18:58:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 23/30] tcg/i386: Introduce tcg_out_testi Date: Wed, 15 Feb 2023 16:57:32 -1000 Message-Id: <20230216025739.1211680-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216025739.1211680-1-richard.henderson@linaro.org> References: <20230216025739.1211680-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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 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 5547f47a26..a75fe91e86 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1729,6 +1729,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); + } +} + #if defined(CONFIG_SOFTMMU) /* * helper signature: helper_ld*_mmu(CPUState *env, target_ulong addr, @@ -2056,18 +2073,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);