From patchwork Tue Jul 12 19:01:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9225973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA04460871 for ; Tue, 12 Jul 2016 19:07:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B97AC277D9 for ; Tue, 12 Jul 2016 19:07:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE51E27D5D; Tue, 12 Jul 2016 19:07:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 492E327CCB for ; Tue, 12 Jul 2016 19:07:54 +0000 (UTC) Received: from localhost ([::1]:42788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bN329-00017U-AK for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Jul 2016 15:07:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bN2xQ-0004v8-Gc for qemu-devel@nongnu.org; Tue, 12 Jul 2016 15:03:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bN2xL-0002aO-7Q for qemu-devel@nongnu.org; Tue, 12 Jul 2016 15:03:00 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:35623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bN2xL-0002aH-1n for qemu-devel@nongnu.org; Tue, 12 Jul 2016 15:02:55 -0400 Received: by mail-qt0-x242.google.com with SMTP id q11so886359qtb.2 for ; Tue, 12 Jul 2016 12:02:54 -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:in-reply-to:references; bh=zfsx/BZgZkJcYNwgW5kAqlrX293nG4FKsJBALyU2PdU=; b=JIRCABVXCkVis6Ry4jZnLhz7DBvGFij+1es/8MUVcujds3C/BfaH2UJFspLtN2QPgm ovKJ0EJutPtP9DcZCxrdNg96GgcLi+Zv+IGte25wt9ScZEDG8VJ3JTdUXmxa3/CfMq5B brYqrsUiX0BtEJ4KCAzjwAsqmXBnjIGkERZmqCWjxZsxcMIluUvTz36lZ3qNh+BuXLE1 7uOE6XPR3SHt7MGtEPwwjUIWz4VbzU6H75ZpNiI1kEJ9yb4Da3FaJcqdP7KJNgpUcboA /28JRVHNw6ZxcsA9v0qMCFKP4TTkS+N5evHfdxQRalzSqq1leby6tL7Oj73abyHTpzJv NBRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=zfsx/BZgZkJcYNwgW5kAqlrX293nG4FKsJBALyU2PdU=; b=j67YF8rocd8OqeDzeV79BoEL64teXw6oxLmMGHUtJ+CvLXl6DRfFFk4+HNIwY6uHph PYerYy/lJsfEKNTezfzOss0kwpA1VcMHr0Fyw5c3wJD8Xay/6/CWK9iTG4sBCSEIRU27 pZx9x0gVRjlBndF4tAY2VuR0UcRGuPkEXXSDzujGO7XY5cKKv72kziiMSlnoHXxcHZ/y hnlTN00yI4AizuA1YCVaP/kDSESN8KCnccKvmteR4XElXJGlm8+Gu80CIa6QcGIFuOCx cytlZzF1eqqJWB5QbsG0Y+iF7UDyODoQeHeS3KcnEzuxu/IzyX5DVcWAOR2znOCylMqC KVcQ== X-Gm-Message-State: ALyK8tLhvEOAwsviW8t02Gy7O6x7t0GtIbUFpXcHEnf2SHIkb6HsG/MlofYM/wdS1+tvZg== X-Received: by 10.200.51.251 with SMTP id d56mr6137676qtb.36.1468350174620; Tue, 12 Jul 2016 12:02:54 -0700 (PDT) Received: from bigtime.com (71-37-54-227.tukw.qwest.net. [71.37.54.227]) by smtp.gmail.com with ESMTPSA id u87sm1209716qkl.30.2016.07.12.12.02.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2016 12:02:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 Jul 2016 12:01:58 -0700 Message-Id: <1468350138-9736-5-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468350138-9736-1-git-send-email-rth@twiddle.net> References: <1468350138-9736-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PULL 04/24] target-sparc: Create gen_exception X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This unifies quite a few duplicate code fragments. Tested-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target-sparc/translate.c | 75 +++++++++++++----------------------------------- 1 file changed, 20 insertions(+), 55 deletions(-) diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 9000e9b..4fb26e7 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -1043,6 +1043,17 @@ static inline void save_state(DisasContext *dc) save_npc(dc); } +static void gen_exception(DisasContext *dc, int which) +{ + TCGv_i32 t; + + save_state(dc); + t = tcg_const_i32(which); + gen_helper_raise_exception(cpu_env, t); + tcg_temp_free_i32(t); + dc->is_br = 1; +} + static inline void gen_mov_pc_npc(DisasContext *dc) { if (dc->npc == JUMP_PC) { @@ -1633,28 +1644,18 @@ static inline void gen_op_fcmpeq(int fccno) } #endif -static inline void gen_op_fpexception_im(int fsr_flags) +static void gen_op_fpexception_im(DisasContext *dc, int fsr_flags) { - TCGv_i32 r_const; - tcg_gen_andi_tl(cpu_fsr, cpu_fsr, FSR_FTT_NMASK); tcg_gen_ori_tl(cpu_fsr, cpu_fsr, fsr_flags); - r_const = tcg_const_i32(TT_FP_EXCP); - gen_helper_raise_exception(cpu_env, r_const); - tcg_temp_free_i32(r_const); + gen_exception(dc, TT_FP_EXCP); } static int gen_trap_ifnofpu(DisasContext *dc) { #if !defined(CONFIG_USER_ONLY) if (!dc->fpu_enabled) { - TCGv_i32 r_const; - - save_state(dc); - r_const = tcg_const_i32(TT_NFPU_INSN); - gen_helper_raise_exception(cpu_env, r_const); - tcg_temp_free_i32(r_const); - dc->is_br = 1; + gen_exception(dc, TT_NFPU_INSN); return 1; } #endif @@ -5155,63 +5156,27 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn) jmp_insn: goto egress; illegal_insn: - { - TCGv_i32 r_const; - - save_state(dc); - r_const = tcg_const_i32(TT_ILL_INSN); - gen_helper_raise_exception(cpu_env, r_const); - tcg_temp_free_i32(r_const); - dc->is_br = 1; - } + gen_exception(dc, TT_ILL_INSN); goto egress; unimp_flush: - { - TCGv_i32 r_const; - - save_state(dc); - r_const = tcg_const_i32(TT_UNIMP_FLUSH); - gen_helper_raise_exception(cpu_env, r_const); - tcg_temp_free_i32(r_const); - dc->is_br = 1; - } + gen_exception(dc, TT_UNIMP_FLUSH); goto egress; #if !defined(CONFIG_USER_ONLY) priv_insn: - { - TCGv_i32 r_const; - - save_state(dc); - r_const = tcg_const_i32(TT_PRIV_INSN); - gen_helper_raise_exception(cpu_env, r_const); - tcg_temp_free_i32(r_const); - dc->is_br = 1; - } + gen_exception(dc, TT_PRIV_INSN); goto egress; #endif nfpu_insn: - save_state(dc); - gen_op_fpexception_im(FSR_FTT_UNIMPFPOP); - dc->is_br = 1; + gen_op_fpexception_im(dc, FSR_FTT_UNIMPFPOP); goto egress; #if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64) nfq_insn: - save_state(dc); - gen_op_fpexception_im(FSR_FTT_SEQ_ERROR); - dc->is_br = 1; + gen_op_fpexception_im(dc, FSR_FTT_SEQ_ERROR); goto egress; #endif #ifndef TARGET_SPARC64 ncp_insn: - { - TCGv r_const; - - save_state(dc); - r_const = tcg_const_i32(TT_NCP_INSN); - gen_helper_raise_exception(cpu_env, r_const); - tcg_temp_free(r_const); - dc->is_br = 1; - } + gen_exception(dc, TT_NCP_INSN); goto egress; #endif egress: