From patchwork Mon Aug 22 23:33:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 599228 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp2040867mae; Mon, 22 Aug 2022 16:51:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR4NEr/MP8ELTLcmBUb55+GgdKJ3kLXZC5qSdsGriYQ0sY6y9zGnII1IeMKPVwPCtL27kp08 X-Received: by 2002:ac8:7f85:0:b0:344:55c5:a2c6 with SMTP id z5-20020ac87f85000000b0034455c5a2c6mr17642012qtj.173.1661212276764; Mon, 22 Aug 2022 16:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661212276; cv=none; d=google.com; s=arc-20160816; b=TJo13J1ZjOxh1c3VDHpEz42LOkqPlDjYhDWwCVuvXvZjAgDO6Akqz+t81O0UeJzY7v lh5e0x8WhjuSCpDWhfIpphpT/Ku8Tq81owollaArgMkGB81BewSkFtJGkpQfpPmZAVJt ardnhoq6SQPhrX/NOuNE3WIcRPV0WETCQ5CfM7EdmK+6RpM3OyzD/Bs7KRtHg26VbmkH Nox4WBNQ+6Yzq3vp+07u5u2NExr1Qq7O5jnbt9WRLaOkDHqvbwwu4WdNNNgyJ833tH6I /9J//nKFbWGASBWnWeZDx9LsAgUQEpsn+5Gdau+Z3nhQiS+CAzRnbG3bVZFuz9m2koKH 52Cw== 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:to:from :dkim-signature; bh=wlQ7TubdU07QaJgJNanX9RFDjUgVlHllrag0UgF/OJg=; b=uNACYbWxkZGu/JXl9epLvDNmRV9ulEh2v1XvJtQJPKtULRJuvJukJ9tl+Y8ksi5MCr sg4zbwGRgen+ckGF7GzH2FjJTuav9e6ldowalTP4VipK46Cwzk8jDEDF3MdOBIKYfupN tDB+QTJ8c0aXJg0zUapCUTepHIO1YrBPpmehdABYFKkrM7dWCAuUrEo2TE805x6CxZp/ qUQuzfFNMqhR2iqZs8Cmib9/tjAMOo4N3gj/9BrSC/stifErYPzsGYZCU+OVkCR2mdEv X1KYq7Y2u2i5TcZDtECwRhhR/4eazU/hovnTd0Rp+8Q5H2t+vMwzRbvB5B71vRPf9yob y4Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bi0LjhkG; 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 j6-20020a05621419c600b0047335940621si5100807qvc.337.2022.08.22.16.51.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Aug 2022 16:51:16 -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=bi0LjhkG; 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]:50628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQHCO-0002eo-Ci for patch@linaro.org; Mon, 22 Aug 2022 19:51:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQGva-0006AL-DP for qemu-devel@nongnu.org; Mon, 22 Aug 2022 19:33:56 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:41946) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQGvW-0007Hb-AC for qemu-devel@nongnu.org; Mon, 22 Aug 2022 19:33:54 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 202so10764579pgc.8 for ; Mon, 22 Aug 2022 16:33:45 -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:to:from:from:to:cc; bh=wlQ7TubdU07QaJgJNanX9RFDjUgVlHllrag0UgF/OJg=; b=bi0LjhkGM7/SS28IJmPhcj5jJF2e/oI9QPsH4NtUHxsvts1p2jymigNNvyU8Xuqe96 8VR8ViscbNMu9Fjb5BEty6k1QO7hjrrQksFOUWiVc9w5XzlqtIxcGqT5noA2GFRdbtCs p4F0UENNQIoJsrR8xq2J+JIJ1O0eN1vFoRjCYFf5qLp+0hVwxy2GuOf3Mv2CFRGmZt+r cr19ewewMqlP6AjW2pGV1SJNYd9l9it54QChD/N5Ih1tRi7R5r4EPDN7bBvE1EURvlJT bT3FwVHVTYwLa7IvH/IuoiYwzjapnf8+7ageKA5+zwb8uTUx+fT5nk20k9lC2RumDkfM 6JOg== 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:to:from:x-gm-message-state:from:to:cc; bh=wlQ7TubdU07QaJgJNanX9RFDjUgVlHllrag0UgF/OJg=; b=a3lYuNfnAzEzvGaQhoRfYqGStn+O4RU/Snw0q/5l5cjoNUKYLoCnhf48jpQhX9Txk6 TYp+ku9v1Md0ar8JFLRIkFtcDfAKHbgbojj9X6OPYZ60vjzzAEAkWMOxMB3QCSsqg3+I Ysbs/5v7viFKeRTOarzvI3ZXp/UEJgup5EvHZpMhXYIhXXrD+C+WxQUhl88rcwC9seXV Kz3hNFJUoImIXJcZ/xHQ3JayVUj7C1pZVLGmhrQ8VBfmFAB5zzRfDVGDGhgFrrw2/y1K R/1qIy3rsT0BsbasFZdbf9eN/XT73jFg5bfBOILZpznD7n1AlJdEzXqY2I7GxiKcwUFi OJaA== X-Gm-Message-State: ACgBeo1ybmEQfY4zV73dUzSJ3M4SbsLRFcX8fZOJVOUfj/Br3I5PUYjX 7SoGq2dVWtRQmnqCz/Xcwh6ePPECo0Uh6g== X-Received: by 2002:a05:6a00:15c4:b0:536:ed66:bb9d with SMTP id o4-20020a056a0015c400b00536ed66bb9dmr1896667pfu.75.1661211224413; Mon, 22 Aug 2022 16:33:44 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:c3f1:b74f:5edd:63af]) by smtp.gmail.com with ESMTPSA id 82-20020a621555000000b0053655af14easm5133124pfv.45.2022.08.22.16.33.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 16:33:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 18/22] target/i386: Use gen_jmp_rel for gen_jcc Date: Mon, 22 Aug 2022 16:33:14 -0700 Message-Id: <20220822233318.1728621-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220822233318.1728621-1-richard.henderson@linaro.org> References: <20220822233318.1728621-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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 --- 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 59e7596629..6d6c751c10 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, @@ -4608,7 +4590,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; @@ -6768,22 +6749,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 */