From patchwork Wed Sep 26 18:48:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11743 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id EB34924146 for ; Wed, 26 Sep 2012 18:49:09 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 89D2BA180DD for ; Wed, 26 Sep 2012 18:49:09 +0000 (UTC) Received: by ieje10 with SMTP id e10so2221642iej.11 for ; Wed, 26 Sep 2012 11:49:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=cRkPFUgZ32cAe6l8Ufri58I4JwBn/eiV2R7oxHQMdJQ=; b=XnJQHSoh8+KK8ydvT2NoxBMY1Q/f8r8buynYeWiRfILcj0xE9R9q/qOY68+isBvRdD V56L2a8UfbRvfTjnYBeXKl8LBToigU7GQH4cxRQLEhcA+dYJGWQMAh+33aUVqHn4c/ZJ in8LtUFCi69nqXFlCxgszlu/BcRSZKw6iz9fvUzO/mNYZ2MVCikqKWtEBluWUZdleuHQ n8S/w52YHavTbbuU1Bw3WtP0lce7Cs+O3FUc8MGIjNuWu+F0kBnAy6cbx+uJWuTqu3mY Q27hiCVloFdeeN1/vtqdV9UMostxgl6IIx5xRJCy5vubyU1gjqgiN0y9fOwgVOqd8vJ0 kjYw== Received: by 10.50.7.212 with SMTP id l20mr1362159iga.43.1348685348785; Wed, 26 Sep 2012 11:49:08 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp373846igc; Wed, 26 Sep 2012 11:49:07 -0700 (PDT) Received: by 10.180.80.134 with SMTP id r6mr3291961wix.1.1348685346692; Wed, 26 Sep 2012 11:49:06 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id k4si601541wea.21.2012.09.26.11.49.03 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 11:49:06 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1TGwfH-0004Mx-Kw; Wed, 26 Sep 2012 19:48:55 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: Richard Henderson , Andrzej Zaborowski , Aurelien Jarno , patches@linaro.org Subject: [PATCH 1/2] tcg/arm: Factor out code to emit immediate or reg-reg op Date: Wed, 26 Sep 2012 19:48:54 +0100 Message-Id: <1348685335-16770-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1348685335-16770-1-git-send-email-peter.maydell@linaro.org> References: <1348685335-16770-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQkSrLsolmD0Kr6hjN/mj5r0Z4zh6rFv0KxhuTj635gSbof4jpC+uzeNybmhxY6TUgwJxhjO The code to emit either an immediate cmp or a register cmp insn is duplicated in several places; factor it out into its own function. Signed-off-by: Peter Maydell Reviewed-by: Aurelien Jarno --- tcg/arm/tcg-target.c | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c index 2bad0a2..a83b295 100644 --- a/tcg/arm/tcg-target.c +++ b/tcg/arm/tcg-target.c @@ -467,6 +467,21 @@ static inline void tcg_out_movi32(TCGContext *s, } } +static inline void tcg_out_dat_rI(TCGContext *s, int cond, int opc, TCGArg dst, + TCGArg lhs, TCGArg rhs, int rhs_is_const) +{ + /* Emit either the reg,imm or reg,reg form of a data-processing insn. + * rhs must satisfy the "rI" constraint. + */ + if (rhs_is_const) { + int rot = encode_imm(rhs); + assert(rot >= 0); + tcg_out_dat_imm(s, cond, opc, dst, lhs, rotl(rhs, rot) | (rot << 7)); + } else { + tcg_out_dat_reg(s, cond, opc, dst, lhs, rhs, SHIFT_IMM_LSL(0)); + } +} + static inline void tcg_out_mul32(TCGContext *s, int cond, int rd, int rs, int rm) { @@ -1591,14 +1606,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, c = ARITH_EOR; /* Fall through. */ gen_arith: - if (const_args[2]) { - int rot; - rot = encode_imm(args[2]); - tcg_out_dat_imm(s, COND_AL, c, - args[0], args[1], rotl(args[2], rot) | (rot << 7)); - } else - tcg_out_dat_reg(s, COND_AL, c, - args[0], args[1], args[2], SHIFT_IMM_LSL(0)); + tcg_out_dat_rI(s, COND_AL, c, args[0], args[1], args[2], const_args[2]); break; case INDEX_op_add2_i32: tcg_out_dat_reg2(s, COND_AL, ARITH_ADD, ARITH_ADC, @@ -1658,15 +1666,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_brcond_i32: - if (const_args[1]) { - int rot; - rot = encode_imm(args[1]); - tcg_out_dat_imm(s, COND_AL, ARITH_CMP, 0, - args[0], rotl(args[1], rot) | (rot << 7)); - } else { - tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, - args[0], args[1], SHIFT_IMM_LSL(0)); - } + tcg_out_dat_rI(s, COND_AL, ARITH_CMP, 0, + args[0], args[1], const_args[1]); tcg_out_goto_label(s, tcg_cond_to_arm_cond[args[2]], args[3]); break; case INDEX_op_brcond2_i32: @@ -1685,15 +1686,8 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_goto_label(s, tcg_cond_to_arm_cond[args[4]], args[5]); break; case INDEX_op_setcond_i32: - if (const_args[2]) { - int rot; - rot = encode_imm(args[2]); - tcg_out_dat_imm(s, COND_AL, ARITH_CMP, 0, - args[1], rotl(args[2], rot) | (rot << 7)); - } else { - tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, - args[1], args[2], SHIFT_IMM_LSL(0)); - } + tcg_out_dat_rI(s, COND_AL, ARITH_CMP, 0, + args[1], args[2], const_args[2]); tcg_out_dat_imm(s, tcg_cond_to_arm_cond[args[3]], ARITH_MOV, args[0], 0, 1); tcg_out_dat_imm(s, tcg_cond_to_arm_cond[tcg_invert_cond(args[3])],