From patchwork Wed May 4 20:12:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9018681 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 25F93BF29F for ; Wed, 4 May 2016 20:30:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 783D52038F for ; Wed, 4 May 2016 20:30:43 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 9E9B3201EC for ; Wed, 4 May 2016 20:30:42 +0000 (UTC) Received: from localhost ([::1]:50154 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay3RO-0008WB-RR for patchwork-qemu-devel@patchwork.kernel.org; Wed, 04 May 2016 16:30:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay3DU-0004xS-8Y for qemu-devel@nongnu.org; Wed, 04 May 2016 16:16:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ay3DI-0004kk-FM for qemu-devel@nongnu.org; Wed, 04 May 2016 16:16:10 -0400 Received: from smtp1-g21.free.fr ([2a01:e0c:1:1599::10]:22702) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ay3DI-0004dk-31 for qemu-devel@nongnu.org; Wed, 04 May 2016 16:16:04 -0400 Received: from Quad.localdomain (unknown [IPv6:2a01:e34:eeee:5240:12c3:7bff:fe6b:9a76]) by smtp1-g21.free.fr (Postfix) with ESMTPS id 35646B0031F; Wed, 4 May 2016 20:09:26 +0200 (CEST) From: Laurent Vivier To: qemu-devel@nongnu.org Date: Wed, 4 May 2016 22:12:09 +0200 Message-Id: <1462392752-17703-30-git-send-email-laurent@vivier.eu> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1462392752-17703-1-git-send-email-laurent@vivier.eu> References: <1462392752-17703-1-git-send-email-laurent@vivier.eu> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 2a01:e0c:1:1599::10 Subject: [Qemu-devel] [PATCH 29/52] target-m68k: factorize flags computing 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: Laurent Vivier , rth@twiddle.net, schwab@linux-m68k.org, agraf@suse.de, gerg@uclinux.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Laurent Vivier --- target-m68k/helper.c | 125 +++++++++++++++++---------------------------------- 1 file changed, 42 insertions(+), 83 deletions(-) diff --git a/target-m68k/helper.c b/target-m68k/helper.c index 42a2f1c..e9e7cee 100644 --- a/target-m68k/helper.c +++ b/target-m68k/helper.c @@ -531,6 +531,46 @@ void HELPER(mac_set_flags)(CPUM68KState *env, uint32_t acc) } } + +#define COMPUTE_CCR(op, x, n, z, v, c) { \ + switch (op) { \ + case CC_OP_FLAGS: \ + /* Everything in place. */ \ + break; \ + case CC_OP_ADD: \ + res = n; \ + src2 = v; \ + src1 = res - src2; \ + c = x; \ + z = n; \ + v = (res ^ src1) & ~(src1 ^ src2); \ + break; \ + case CC_OP_SUB: \ + res = n; \ + src2 = v; \ + src1 = res + src2; \ + c = x; \ + z = n; \ + v = (res ^ src1) & (src1 ^ src2); \ + break; \ + case CC_OP_CMP: \ + src1 = n; \ + src2 = v; \ + res = src1 - src2; \ + n = res; \ + z = res; \ + c = src1 < src2; \ + v = (res ^ src1) & (src1 ^ src2); \ + break; \ + case CC_OP_LOGIC: \ + c = v = 0; \ + z = n; \ + break; \ + default: \ + cpu_abort(CPU(m68k_env_get_cpu(env)), "Bad CC_OP %d", op); \ + } \ +} while (0) + uint32_t cpu_m68k_get_ccr(CPUM68KState *env) { uint32_t x, c, n, z, v; @@ -542,47 +582,7 @@ uint32_t cpu_m68k_get_ccr(CPUM68KState *env) z = env->cc_z; v = env->cc_v; - switch (env->cc_op) { - case CC_OP_FLAGS: - /* Everything in place. */ - break; - - case CC_OP_ADD: - res = n; - src2 = v; - src1 = res - src2; - c = x; - z = n; - v = (res ^ src1) & ~(src1 ^ src2); - break; - - case CC_OP_SUB: - res = n; - src2 = v; - src1 = res + src2; - c = x; - z = n; - v = (res ^ src1) & (src1 ^ src2); - break; - - case CC_OP_CMP: - src1 = n; - src2 = v; - res = src1 - src2; - n = res; - z = res; - c = src1 < src2; - v = (res ^ src1) & (src1 ^ src2); - break; - - case CC_OP_LOGIC: - c = v = 0; - z = n; - break; - - default: - cpu_abort(CPU(m68k_env_get_cpu(env)), "Bad CC_OP %d", env->cc_op); - } + COMPUTE_CCR(env->cc_op, x, n, z, v, c); n = n >> 31; v = v >> 31; @@ -615,48 +615,7 @@ void HELPER(flush_flags)(CPUM68KState *env, uint32_t cc_op) { uint32_t res, src1, src2; - switch (cc_op) { - case CC_OP_FLAGS: - /* Everything up to date. */ - return; - - case CC_OP_ADD: - res = env->cc_n; - src2 = env->cc_v; - src1 = res - src2; - env->cc_z = res; - env->cc_c = env->cc_x; - env->cc_v = (res ^ src1) & ~(src1 ^ src2); - break; - - case CC_OP_SUB: - res = env->cc_n; - src2 = env->cc_v; - src1 = res + src2; - env->cc_z = res; - env->cc_c = env->cc_x; - env->cc_v = (res ^ src1) & (src1 ^ src2); - break; - - case CC_OP_CMP: - src1 = env->cc_n; - src2 = env->cc_v; - res = src1 - src2; - env->cc_n = res; - env->cc_z = res; - env->cc_c = src1 < src2; - env->cc_v = (res ^ src1) & (src1 ^ src2); - break; - - case CC_OP_LOGIC: - env->cc_c = 0; - env->cc_v = 0; - env->cc_z = env->cc_n; - break; - - default: - cpu_abort(CPU(m68k_env_get_cpu(env)), "Bad CC_OP %d", cc_op); - } + COMPUTE_CCR(cc_op, env->cc_x, env->cc_n, env->cc_z, env->cc_v, env->cc_c); env->cc_op = CC_OP_FLAGS; }