From patchwork Tue Sep 6 10:09:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 603004 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp4415370mae; Tue, 6 Sep 2022 04:00:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7yxjsr/NjhTcQnmZkiAyAxNSZ80mOKOrktBRDMIF4OOV3YypOpTUgC9p0deerz8K9twcWG X-Received: by 2002:a05:622a:14cd:b0:344:6cfa:42f9 with SMTP id u13-20020a05622a14cd00b003446cfa42f9mr43256122qtx.147.1662462034852; Tue, 06 Sep 2022 04:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662462034; cv=none; d=google.com; s=arc-20160816; b=BI69AsAQzKUymkjb5oIvxHHJg704F2qatUSCzMnairg0qIIOLpQDXUavXsOMRUtvyU NYoV8TadrmzIqURK++y5sRhOmZWQ+DPkLjUZbCCRelZag3lRM/sw58fa/N4QteU4D2Cg zOoNI+DlPR0enPV01Aslj3wLxog9yta4EZZEqz8kVW+BE7jzM+CEtPsYzl732FJsnAlP nvfvt8kron7wJHRgv+ALnv5ReA8sTa9MkdxaXuvr0LDaSDnUaFmo37bPoGt01ADaNv/n q1uylaAcimA+zFYhOukeey8S9fKNNOePe/OhdGZPC1g5OmUqXtyaTWD2pwkyUFKfAYVi wkaw== 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=rSER7sme+GIaasRDe61/7EyMKFpjNEQVvBAOzaCcze4=; b=fwgHfIAYJvf9TzJ1JP4QCS3VcBamuwpTdjf+127KQxcIZZXRSikFQb64Wf4OAjZwXI I1zPe6C930+thkjjJuD0n6nZN0Ass74cbEDuMOLLYtbJBK2Hp+VgrxGytneHQyUO/rfv s4qQebH72ZYMwH7ktBd65cMYYiqJOtXCUWtwkbEL94+WalogQGmIb4q3QKpqOuoyRPt9 WxxEpaWEplUAZDWKvHU89CiAJ5BH6k2RfM8MaZHdYDO2HCrQWqcanZp45DVbOyd2qqfA vKVeGr207pcfHUE43+Sl1l/eIy337TUZit7Mwrgfa3uKqAPODahEOZ3L2QbriKSV+9mj 1+BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aNUax3CR; 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 cm20-20020a05622a251400b0031ed9558bb5si7455842qtb.522.2022.09.06.04.00.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Sep 2022 04:00:34 -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=aNUax3CR; 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]:54786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVWJl-0004E0-Fh for patch@linaro.org; Tue, 06 Sep 2022 07:00:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVVWl-0000Gq-JV for qemu-devel@nongnu.org; Tue, 06 Sep 2022 06:09:58 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:39866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVVWj-0003c5-Ra for qemu-devel@nongnu.org; Tue, 06 Sep 2022 06:09:55 -0400 Received: by mail-wr1-x42d.google.com with SMTP id az27so14662117wrb.6 for ; Tue, 06 Sep 2022 03:09:53 -0700 (PDT) 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; bh=rSER7sme+GIaasRDe61/7EyMKFpjNEQVvBAOzaCcze4=; b=aNUax3CR9ts3r9y2gPmUEbPMdnx1BNBDvTxe0AWwwx6i1xV/oKBaD+4RKee8B2Lb0e ZrWSDQzTj5d6GTkY5UngDTBtz0qLPAzFzCwYG5iONRqHLREu1x6xqGmgy6CVG/pDKDqY B6nxH7j7x2K4hy9jTbxbI2rj0A7gWJEJ923L741IRqMTSqli9LAy24498XynVuseOGtq JqgUX6LnD30RDUL16cVq78nZ+aSeaeOhieF/B11vP1qjl8ddy/cMZlFV97xKVR/tJf6a DHtqAcd1gESg9pwRpL63iuZeQQM71P06A+t4dFMERMGI6gTipzKd1vfGjs+0mAYeIDu8 e8OQ== 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; bh=rSER7sme+GIaasRDe61/7EyMKFpjNEQVvBAOzaCcze4=; b=Kf/pi2RD8zut868HAKa65lShNW8unXAIxJSsOkDq/qfN8mfzFHHspkVJuP1u6tTw8O 93mkPOSFHukn3L2a/91yXEzpvqd3Nwo24nN++Sx5S67PGsxdPkh0hmsn12+yMo2QxNC2 DI2mK2XDHb+7KUZaN1RsayNiK5uuUesgNpZjnx0WppGbFFuGZpDo8BmUTS6UjzXk55CG mIslV/fWgSbznclbSpJMWQVgza2a3uMK5MQ5eszzY7cDeSz7dzhDdkQU9wcFncuzlDpN dN+0fCFNfoqd8G8SuDYP8kJz52RBRP0CzPanVNaNCgQwAM6GA0ZI9cfksbGHjY8241QI GpYA== X-Gm-Message-State: ACgBeo2XFhGhdcFTTBhTv+y0b1suGNNVG/2hbuvt8HK/B8KN5NhDPdZe tLhuSsJqt51s1wdPOzgVRhVLs4gAv7op2NDP X-Received: by 2002:a05:6000:1805:b0:228:60f7:4dfb with SMTP id m5-20020a056000180500b0022860f74dfbmr8103305wrh.351.1662458992555; Tue, 06 Sep 2022 03:09:52 -0700 (PDT) Received: from localhost.localdomain ([2a02:8084:a5c0:5a80:ba98:3a71:8524:e0b1]) by smtp.gmail.com with ESMTPSA id f25-20020a1c6a19000000b003a840690609sm23125014wmc.36.2022.09.06.03.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 03:09:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com Subject: [PATCH v2 19/23] target/i386: Use gen_jmp_rel for gen_jcc Date: Tue, 6 Sep 2022 11:09:28 +0100 Message-Id: <20220906100932.343523-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220906100932.343523-1-richard.henderson@linaro.org> References: <20220906100932.343523-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42d.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" Signed-off-by: Richard Henderson Reviewed-by: Paolo Bonzini --- target/i386/tcg/translate.c | 57 ++++++++++++------------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index fdd17c3cf3..e27f36e4e9 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -2373,32 +2373,14 @@ static void gen_goto_tb(DisasContext *s, int tb_num, target_ulong eip) } } -static inline void gen_jcc(DisasContext *s, int b, - target_ulong val, target_ulong next_eip) +static void gen_jcc(DisasContext *s, MemOp ot, int b, int diff) { - TCGLabel *l1, *l2; + TCGLabel *l1 = gen_new_label(); - if (s->jmp_opt) { - l1 = gen_new_label(); - gen_jcc1(s, b, l1); - - gen_goto_tb(s, 0, next_eip); - - gen_set_label(l1); - gen_goto_tb(s, 1, val); - } else { - l1 = gen_new_label(); - l2 = gen_new_label(); - gen_jcc1(s, b, l1); - - gen_jmp_im(s, next_eip); - tcg_gen_br(l2); - - gen_set_label(l1); - gen_jmp_im(s, val); - gen_set_label(l2); - gen_eob(s); - } + gen_jcc1(s, b, l1); + gen_jmp_rel(s, ot, 0, 1); + gen_set_label(l1); + gen_jmp_rel(s, ot, diff, 0); } static void gen_cmovcc1(CPUX86State *env, DisasContext *s, MemOp ot, int b, @@ -4721,7 +4703,6 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) int shift; MemOp ot, aflag, dflag; int modrm, reg, rm, mod, op, opreg, val; - target_ulong next_eip, tval; bool orig_cc_op_dirty = s->cc_op_dirty; CCOp orig_cc_op = s->cc_op; @@ -6881,22 +6862,20 @@ static bool disas_insn(DisasContext *s, CPUState *cpu) } break; case 0x70 ... 0x7f: /* jcc Jb */ - tval = (int8_t)insn_get(env, s, MO_8); - goto do_jcc; + { + int diff = (int8_t)insn_get(env, s, MO_8); + gen_bnd_jmp(s); + gen_jcc(s, dflag, b, diff); + } + break; case 0x180 ... 0x18f: /* jcc Jv */ - if (dflag != MO_16) { - tval = (int32_t)insn_get(env, s, MO_32); - } else { - tval = (int16_t)insn_get(env, s, MO_16); + { + int diff = (dflag != MO_16 + ? (int32_t)insn_get(env, s, MO_32) + : (int16_t)insn_get(env, s, MO_16)); + gen_bnd_jmp(s); + gen_jcc(s, dflag, b, diff); } - do_jcc: - next_eip = s->pc - s->cs_base; - tval += next_eip; - if (dflag == MO_16) { - tval &= 0xffff; - } - gen_bnd_jmp(s); - gen_jcc(s, b, tval, next_eip); break; case 0x190 ... 0x19f: /* setcc Gv */