From patchwork Thu Mar 21 20:01:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 229826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 309212C00C0 for ; Fri, 22 Mar 2013 07:03:17 +1100 (EST) Received: from localhost ([::1]:57506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIlhj-00086f-BH for incoming@patchwork.ozlabs.org; Thu, 21 Mar 2013 16:03:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIlh6-0007sF-Ho for qemu-devel@nongnu.org; Thu, 21 Mar 2013 16:02:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIlh0-0002Ws-6V for qemu-devel@nongnu.org; Thu, 21 Mar 2013 16:02:36 -0400 Received: from mail-vc0-f174.google.com ([209.85.220.174]:37794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIlh0-0002Wh-2q; Thu, 21 Mar 2013 16:02:30 -0400 Received: by mail-vc0-f174.google.com with SMTP id hx10so2588132vcb.19 for ; Thu, 21 Mar 2013 13:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=r5E/AzAolkdxELy5NI5Hp+AkY327uxJBaGTNhTrb5OQ=; b=TiLdGJHnRORnYrXK8t7Y1yH0xvOkkx3I74vxyJHC9rAwBr3QfhcFbjQ6U6DQfzdq3h /Bp7QjRtH4/f3PEOObLsxnokGIqGKvt2EDF/69mB8+h7m+IwQyKRbz14F57b5nayTBkk XhfiaW5RnQKnIlA6R60C52I0R7tE/f+9EcrSM1Ux4rmvK5EiqJKy8kDwplv/mssZt+EF vZlnVipkTnIYbLkHZxCQRgziihh96MH99FrQjhxF0xGelmBq+py43tc7aikZxLp0EJY5 fZGuP2IlX2Ei+5BKfNRCaEStAkF96b2Nb2/SkqeK+VfPvDz22Vj6E+NDSkm7GXxsyMrM SYew== X-Received: by 10.58.96.72 with SMTP id dq8mr15156277veb.49.1363896149667; Thu, 21 Mar 2013 13:02:29 -0700 (PDT) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id q5sm42948551vdj.5.2013.03.21.13.02.26 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 21 Mar 2013 13:02:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 21 Mar 2013 13:01:46 -0700 Message-Id: <1363896109-22776-3-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1363896109-22776-1-git-send-email-rth@twiddle.net> References: <1363896109-22776-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.174 Cc: qemu-ppc@nongnu.org, agraf@suse.de Subject: [Qemu-devel] [PATCH 2/5] target-ppc: Use NARROW_MODE macro for branches X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Removing conditional compilation in the process. Signed-off-by: Richard Henderson --- target-ppc/translate.c | 62 +++++++++++++++++++------------------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/target-ppc/translate.c b/target-ppc/translate.c index ed6415c..92b4f6c 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -267,12 +267,10 @@ static inline void gen_set_access_type(DisasContext *ctx, int access_type) static inline void gen_update_nip(DisasContext *ctx, target_ulong nip) { -#if defined(TARGET_PPC64) - if (ctx->sf_mode) - tcg_gen_movi_tl(cpu_nip, nip); - else -#endif - tcg_gen_movi_tl(cpu_nip, (uint32_t)nip); + if (NARROW_MODE(ctx)) { + nip = (uint32_t)nip; + } + tcg_gen_movi_tl(cpu_nip, nip); } static inline void gen_exception_err(DisasContext *ctx, uint32_t excp, uint32_t error) @@ -3352,10 +3350,9 @@ static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest) { TranslationBlock *tb; tb = ctx->tb; -#if defined(TARGET_PPC64) - if (!ctx->sf_mode) + if (NARROW_MODE(ctx)) { dest = (uint32_t) dest; -#endif + } if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) && likely(!ctx->singlestep_enabled)) { tcg_gen_goto_tb(n); @@ -3383,12 +3380,10 @@ static inline void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest) static inline void gen_setlr(DisasContext *ctx, target_ulong nip) { -#if defined(TARGET_PPC64) - if (ctx->sf_mode == 0) - tcg_gen_movi_tl(cpu_lr, (uint32_t)nip); - else -#endif - tcg_gen_movi_tl(cpu_lr, nip); + if (NARROW_MODE(ctx)) { + nip = (uint32_t)nip; + } + tcg_gen_movi_tl(cpu_lr, nip); } /* b ba bl bla */ @@ -3398,18 +3393,16 @@ static void gen_b(DisasContext *ctx) ctx->exception = POWERPC_EXCP_BRANCH; /* sign extend LI */ -#if defined(TARGET_PPC64) - if (ctx->sf_mode) - li = ((int64_t)LI(ctx->opcode) << 38) >> 38; - else -#endif - li = ((int32_t)LI(ctx->opcode) << 6) >> 6; - if (likely(AA(ctx->opcode) == 0)) + li = LI(ctx->opcode); + li = (li ^ 0x02000000) - 0x02000000; + if (likely(AA(ctx->opcode) == 0)) { target = ctx->nip + li - 4; - else + } else { target = li; - if (LK(ctx->opcode)) + } + if (LK(ctx->opcode)) { gen_setlr(ctx, ctx->nip); + } gen_update_cfar(ctx, ctx->nip); gen_goto_tb(ctx, 0, target); } @@ -3445,12 +3438,11 @@ static inline void gen_bcond(DisasContext *ctx, int type) return; } tcg_gen_subi_tl(cpu_ctr, cpu_ctr, 1); -#if defined(TARGET_PPC64) - if (!ctx->sf_mode) + if (NARROW_MODE(ctx)) { tcg_gen_ext32u_tl(temp, cpu_ctr); - else -#endif + } else { tcg_gen_mov_tl(temp, cpu_ctr); + } if (bo & 0x2) { tcg_gen_brcondi_tl(TCG_COND_NE, temp, 0, l1); } else { @@ -3484,20 +3476,14 @@ static inline void gen_bcond(DisasContext *ctx, int type) gen_set_label(l1); gen_goto_tb(ctx, 1, ctx->nip); } else { -#if defined(TARGET_PPC64) - if (!(ctx->sf_mode)) + if (NARROW_MODE(ctx)) { tcg_gen_andi_tl(cpu_nip, target, (uint32_t)~3); - else -#endif + } else { tcg_gen_andi_tl(cpu_nip, target, ~3); + } tcg_gen_exit_tb(0); gen_set_label(l1); -#if defined(TARGET_PPC64) - if (!(ctx->sf_mode)) - tcg_gen_movi_tl(cpu_nip, (uint32_t)ctx->nip); - else -#endif - tcg_gen_movi_tl(cpu_nip, ctx->nip); + gen_update_nip(ctx, ctx->nip); tcg_gen_exit_tb(0); } }