From patchwork Fri Sep 28 00:55:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 187657 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 CAB4D2C00AB for ; Fri, 28 Sep 2012 10:55:20 +1000 (EST) Received: from localhost ([::1]:59861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THOrP-0005zt-1b for incoming@patchwork.ozlabs.org; Thu, 27 Sep 2012 20:55:19 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THOrF-0005zb-HI for qemu-devel@nongnu.org; Thu, 27 Sep 2012 20:55:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THOrE-0005Ra-0e for qemu-devel@nongnu.org; Thu, 27 Sep 2012 20:55:09 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:37232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THOrD-0005QK-NS for qemu-devel@nongnu.org; Thu, 27 Sep 2012 20:55:07 -0400 Received: by pbbrp2 with SMTP id rp2so4381828pbb.4 for ; Thu, 27 Sep 2012 17:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=wriRCTovxLAgy0N3iYcZmMBrwY2pCWQG7giQG6jOprU=; b=M58zwyhymcCka5sZ3CiJiN9//yDzXRQtBO+fhmL9v0LrzjRm5zRuMbYFL6+q2hZRHV c6bhKc9xZ3oA3VB9P8QF90zfxUdrEjE8JkRouCSdr+A4ZToGzBcST2owmNOos4cdXAUS tji3y8IfgLJIaZu1D0XX8OWLXC4bi5OcbQN1aalc52DDjRWVOA3XudMyef7H7m8jG4Ho okWdEcbWVE8jbI1ZbZ1PQ/R1FSVfhgWyP7IwhYEOjn+6LFX7cN+GOnKnkx0FSgfA9lIQ 5j9ZkUgZ3qnl6aDDL0xIiNMEyMElnVBwh+3DMJjJVkoaoNhsi9QgW7aTqR2slZwgEV7F a0mg== Received: by 10.66.77.7 with SMTP id o7mr13528175paw.37.1348793706975; Thu, 27 Sep 2012 17:55:06 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id oe5sm4653785pbb.8.2012.09.27.17.55.05 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 17:55:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 27 Sep 2012 17:55:03 -0700 Message-Id: <1348793703-27826-1-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348785610-23418-1-git-send-email-rth@twiddle.net> References: <1348785610-23418-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Alexander Graf Subject: [Qemu-devel] [PATCH 119/147] target-s390: Tidy s->op_cc handling 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 There's no need to force computation of the true cc_op when taking an exception or single stepping. In either case we'll enter the next TB with s->cc_op = DYNAMIC and recompute anyway. Just make sure that s->cc_op is stored back to env->cc_op as needed. Delete some dead functions, avoid allocating unused TCG temps, drop the old s->is_jmp setting. Signed-off-by: Richard Henderson --- target-s390x/translate.c | 95 ++++++++++++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 40 deletions(-) diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 74f14bc..fdb31cd 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -55,7 +55,6 @@ struct DisasContext { uint64_t pc, next_pc; enum cc_op cc_op; bool singlestep_enabled; - int is_jmp; }; /* Information carried about a condition to be evaluated. */ @@ -72,8 +71,6 @@ typedef struct { #define DISAS_EXCP 4 -static void gen_op_calc_cc(DisasContext *s); - #ifdef DEBUG_INLINE_BRANCHES static uint64_t inline_branch_hit[CC_OP_MAX]; static uint64_t inline_branch_miss[CC_OP_MAX]; @@ -246,12 +243,17 @@ static void update_psw_addr(DisasContext *s) tcg_gen_movi_i64(psw_addr, s->pc); } +static void update_cc_op(DisasContext *s) +{ + if (s->cc_op != CC_OP_DYNAMIC && s->cc_op != CC_OP_STATIC) { + tcg_gen_movi_i32(cc_op, s->cc_op); + } +} + static void potential_page_fault(DisasContext *s) { -#ifndef CONFIG_USER_ONLY update_psw_addr(s); - gen_op_calc_cc(s); -#endif + update_cc_op(s); } static inline uint64_t ld_code2(CPUS390XState *env, uint64_t pc) @@ -309,13 +311,10 @@ static void gen_program_exception(DisasContext *s, int code) update_psw_addr(s); /* Save off cc. */ - gen_op_calc_cc(s); + update_cc_op(s); /* Trigger exception. */ gen_exception(EXCP_PGM); - - /* End TB here. */ - s->is_jmp = DISAS_EXCP; } static inline void gen_illegal_opcode(DisasContext *s) @@ -428,23 +427,40 @@ static void set_cc_static(DisasContext *s) s->cc_op = CC_OP_STATIC; } -static void gen_op_set_cc_op(DisasContext *s) -{ - if (s->cc_op != CC_OP_DYNAMIC && s->cc_op != CC_OP_STATIC) { - tcg_gen_movi_i32(cc_op, s->cc_op); - } -} - -static void gen_update_cc_op(DisasContext *s) -{ - gen_op_set_cc_op(s); -} - /* calculates cc into cc_op */ static void gen_op_calc_cc(DisasContext *s) { - TCGv_i32 local_cc_op = tcg_const_i32(s->cc_op); - TCGv_i64 dummy = tcg_const_i64(0); + TCGv_i32 local_cc_op; + TCGv_i64 dummy; + + TCGV_UNUSED_I32(local_cc_op); + TCGV_UNUSED_I64(dummy); + switch (s->cc_op) { + default: + dummy = tcg_const_i64(0); + /* FALLTHRU */ + case CC_OP_ADD_64: + case CC_OP_ADDU_64: + case CC_OP_ADDC_64: + case CC_OP_SUB_64: + case CC_OP_SUBU_64: + case CC_OP_SUBB_64: + case CC_OP_ADD_32: + case CC_OP_ADDU_32: + case CC_OP_ADDC_32: + case CC_OP_SUB_32: + case CC_OP_SUBU_32: + case CC_OP_SUBB_32: + local_cc_op = tcg_const_i32(s->cc_op); + break; + case CC_OP_CONST0: + case CC_OP_CONST1: + case CC_OP_CONST2: + case CC_OP_CONST3: + case CC_OP_STATIC: + case CC_OP_DYNAMIC: + break; + } switch (s->cc_op) { case CC_OP_CONST0: @@ -508,8 +524,12 @@ static void gen_op_calc_cc(DisasContext *s) tcg_abort(); } - tcg_temp_free_i32(local_cc_op); - tcg_temp_free_i64(dummy); + if (!TCGV_IS_UNUSED_I32(local_cc_op)) { + tcg_temp_free_i32(local_cc_op); + } + if (!TCGV_IS_UNUSED_I64(dummy)) { + tcg_temp_free_i64(dummy); + } /* We now have cc in cc_op as constant */ set_cc_static(s); @@ -1054,7 +1074,7 @@ static ExitStatus help_goto_direct(DisasContext *s, uint64_t dest) return NO_EXIT; } if (use_goto_tb(s, dest)) { - gen_update_cc_op(s); + update_cc_op(s); tcg_gen_goto_tb(0); tcg_gen_movi_i64(psw_addr, dest); tcg_gen_exit_tb((tcg_target_long)s->tb); @@ -1103,7 +1123,7 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c, if (use_goto_tb(s, s->next_pc)) { if (is_imm && use_goto_tb(s, dest)) { /* Both exits can use goto_tb. */ - gen_update_cc_op(s); + update_cc_op(s); lab = gen_new_label(); if (c->is_64) { @@ -1141,7 +1161,7 @@ static ExitStatus help_branch(DisasContext *s, DisasCompare *c, } /* Branch not taken. */ - gen_update_cc_op(s); + update_cc_op(s); tcg_gen_goto_tb(0); tcg_gen_movi_i64(psw_addr, s->next_pc); tcg_gen_exit_tb((tcg_target_long)s->tb + 0); @@ -1749,7 +1769,7 @@ static ExitStatus op_ex(DisasContext *s, DisasOps *o) TCGv_i64 tmp; update_psw_addr(s); - gen_op_calc_cc(s); + update_cc_op(s); tmp = tcg_const_i64(s->next_pc); gen_helper_ex(cc_op, cpu_env, cc_op, o->in1, o->in2, tmp); @@ -2913,7 +2933,7 @@ static ExitStatus op_svc(DisasContext *s, DisasOps *o) TCGv_i32 t; update_psw_addr(s); - gen_op_calc_cc(s); + update_cc_op(s); t = tcg_const_i32(get_field(s->fields, i1) & 0xff); tcg_gen_st_i32(t, cpu_env, offsetof(CPUS390XState, int_svc_code)); @@ -3999,7 +4019,6 @@ static inline void gen_intermediate_code_internal(CPUS390XState *env, dc.pc = pc_start; dc.cc_op = CC_OP_DYNAMIC; do_debug = dc.singlestep_enabled = env->singlestep_enabled; - dc.is_jmp = DISAS_NEXT; gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; @@ -4073,17 +4092,13 @@ static inline void gen_intermediate_code_internal(CPUS390XState *env, update_psw_addr(&dc); /* FALLTHRU */ case EXIT_PC_UPDATED: - if (singlestep && dc.cc_op != CC_OP_DYNAMIC) { - gen_op_calc_cc(&dc); - } else { - /* Next TB starts off with CC_OP_DYNAMIC, - so make sure the cc op type is in env */ - gen_op_set_cc_op(&dc); - } + /* Next TB starts off with CC_OP_DYNAMIC, so make sure the + cc op type is in env */ + update_cc_op(&dc); + /* Exit the TB, either by raising a debug exception or by return. */ if (do_debug) { gen_exception(EXCP_DEBUG); } else { - /* Generate the return instruction */ tcg_gen_exit_tb(0); } break;