From patchwork Fri May 5 21:24:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 679333 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp579454wrs; Fri, 5 May 2023 14:27:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4vDe1f0xp4Vvzx+U5PWS62atgRLZZM5vMHVcDV025hxF7tTmTaHhvb1dgjei4c4BqOknGM X-Received: by 2002:a05:6214:246a:b0:61b:17bd:c5fc with SMTP id im10-20020a056214246a00b0061b17bdc5fcmr4745879qvb.12.1683322045791; Fri, 05 May 2023 14:27:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683322045; cv=none; d=google.com; s=arc-20160816; b=H4NWLoqlW0QsGQ+5Yrql5eNIKyohzHSlyIKCFnEDDHd4gPJaB8z9GW83G4qfHdc6i3 nj3Z/SiW8Fpgnt++LBlpv8mys4Md0CB3QOPSQkzs07WngMgZa8qXMdHtl21xx3w8Fb15 6XPzgHTUcekc/MmGuqR4w69Eg6w3wNeEpSdO7c54BlKiUMqKaPqSxR7FnaipnmP78sfC OkJiQ/o0p4VPfeV7FB7jKXIm74t+zZ6J7MX1AQ6yPiCc/8wMOtNycnlVnV0wnDCvvBas l3F3EsS2CU5KgBu/7opZGiFLK4Pug6xTbOc24bXLyu7rffH2ldW2P66Dh6dblWDaNl5j 5OKQ== 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=l0A/LgUi4z6B1lwW4uNcjXdWAYm4PmHLzeyxMeuQV08=; b=Ailjy8Uom4hc1aTSJMeUIRDuUiO6kkuhNGcW8wdZrhNtdlIPAizYj0SZTt5YPw5Ads M8ATJuBRLCx1bxSB7e/nA+7noxezCIlcjbMLP8H33KepGp6SSYgSdrK+m73ZkBEwI8XN QVb6RCMJRE1dz48WQ/acaGGz4rxpiWUsm4uzXIsbdqZzmhrytIPBzONoShde1JvuN50g Aa7qj89n+jywHS/GUo4uhpRsc/ojXVWDjcHazxDRILoYmQ1TTArDJieKSPNUuiBaGpor yJRq880LnQv4qGectZf9wQeF9tJZXigU68qT7RgmVwBcloQT1i5zdf7Aw8669GmQkmtc jreg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JVY0lvMp; 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 a3-20020a05620a124300b0074a205a138esi947940qkl.649.2023.05.05.14.27.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 May 2023 14:27:25 -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=JVY0lvMp; 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 1pv2ve-0000sN-Fc; Fri, 05 May 2023 17:25:26 -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 1pv2vV-0000oZ-Ck for qemu-devel@nongnu.org; Fri, 05 May 2023 17:25:17 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pv2vH-0004TJ-LR for qemu-devel@nongnu.org; Fri, 05 May 2023 17:25:17 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f173af665fso15920855e9.3 for ; Fri, 05 May 2023 14:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683321901; x=1685913901; 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=l0A/LgUi4z6B1lwW4uNcjXdWAYm4PmHLzeyxMeuQV08=; b=JVY0lvMpyVLRAVSp/Z6fB/aClgYH0Lg2BZ0yKWpmWY2KFECZ+d8KW//52TJJF6IEM7 G9r1gqBmo3ZUJSaSw8GvxZqVR1vq4SwZdK3CRrLGR3J6cX5KYRkhUUcOlfJLtgnfD3HP L2RyWkOa6AQGm/gEu0yWXpoVbYP3rVQMHiPy0beH1tz27vKVrCLVV0eQ7eYD/wdJUDlN MQap36yWYu7mKFTaY/pwhN/xWnPVbliEqLHh7mBDmV0V9/LbheAlVxYw3jNI5CeF2cz8 V2MLnmfTBQfJsYeQ4qutTPJdX39qdGj79m/fzFv53hm5Vhn6vJ6HAlZ1e22U4OAlVCeP O0nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683321901; x=1685913901; 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=l0A/LgUi4z6B1lwW4uNcjXdWAYm4PmHLzeyxMeuQV08=; b=coZ/4Zde/K9f3RWjRjkOtOr3v9yQC3ZFJHi0XsH5fljPD2AfyGVpSHjcp4iQvinjuU KJ9r6aGbQDyFLOqy8USa65bBe47HleexnQK80gKMglNERbw2viIhzV8WnsfZQ5bEQJ1E onZa4s0pVB3e4mMwse/j/0isu+T01Vp2Z8q/ozbNhwpY4q8cvvhKN+JHllsSU/XoJFeY tOiBgaS3DCEbjqMdDO7+Ut2Y/7r9JkOB93tuWXyHCH3N2WEOxju0iSnth5WagWSQBt4T ufhk7eHoekPM2hg3o/mkwGqh+cDNeeAAH0+ti6Yy0CFIx0aXRLuBacPOUbsAMTff+gkt TgfA== X-Gm-Message-State: AC+VfDzj6s3oReW8MotdmoJQf9kgJME+/vOIKwiRxzQH1arSgT3IJfGb gimPQsPGEe01UTer42Cgb2yNZcxfiY2LNwXYN2cgcw== X-Received: by 2002:a7b:cb57:0:b0:3f1:7a4a:7f9 with SMTP id v23-20020a7bcb57000000b003f17a4a07f9mr2094554wmj.7.1683321901521; Fri, 05 May 2023 14:25:01 -0700 (PDT) Received: from stoup.. ([212.241.182.8]) by smtp.gmail.com with ESMTPSA id t14-20020a5d460e000000b003047ae72b14sm3426709wrq.82.2023.05.05.14.25.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 May 2023 14:25:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 23/42] tcg/i386: Introduce tcg_out_testi Date: Fri, 5 May 2023 22:24:28 +0100 Message-Id: <20230505212447.374546-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230505212447.374546-1-richard.henderson@linaro.org> References: <20230505212447.374546-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32c.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, 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 78160f453b..aae698121a 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1751,6 +1751,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; @@ -2051,18 +2068,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);