From patchwork Thu Oct 3 12:51:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 20786 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f198.google.com (mail-ye0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 88125266EC for ; Thu, 3 Oct 2013 12:51:10 +0000 (UTC) Received: by mail-ye0-f198.google.com with SMTP id m11sf3777979yen.9 for ; Thu, 03 Oct 2013 05:51:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:cc:subject:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=TQFEibeFN2iHJze2YF0hXBV3kmqPTMYzccwdYd2eGC4=; b=DDyAikoRvabNY9f9+vtHY4NJr3HmlvLUIvsSYP6+8pFVLk0t3b8GQGzKPi+pUkIKaP jh6MGVj7BC67ZdT2FPBBUHCCWVCKUCl/xWIKLXDbRD0ZzcmsJlkwC+yT7BvUEF0t/0iO d3vt1WqwRvUa9ao7XqVJv9MUkPzsGwex56U9WcMpA8dOLUXPfH9YfhD0zBj/MVd6LmwM 6FD9ptddULD2Orl5Y+sJ8fHSjVaXRJPzeJYiKcdba7SF87893iV98hnRa9uENwFfm1fg O3AlM2YoDJP9kJoBFJK31eTXmHYjSwlyG3qxgXGdU2iDmoHg9V38Co0ZjJsdEfiyhhB7 EYMg== X-Received: by 10.236.73.164 with SMTP id v24mr6821494yhd.24.1380804670028; Thu, 03 Oct 2013 05:51:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.108.230 with SMTP id hn6ls901398qeb.81.gmail; Thu, 03 Oct 2013 05:51:09 -0700 (PDT) X-Received: by 10.52.37.69 with SMTP id w5mr477185vdj.32.1380804669922; Thu, 03 Oct 2013 05:51:09 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id is10si1676205veb.146.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 05:51:09 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so1626629veb.2 for ; Thu, 03 Oct 2013 05:51:09 -0700 (PDT) X-Gm-Message-State: ALoCoQn4VI4twqRFv6sdgR3wGTqM/mk7FpN/5nDRp9OTQrtQMwcGlEk9iQWWvpIILz7hZi4cPfDH X-Received: by 10.52.173.165 with SMTP id bl5mr6299395vdc.18.1380804669547; Thu, 03 Oct 2013 05:51:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp175717vcz; Thu, 3 Oct 2013 05:51:08 -0700 (PDT) X-Received: by 10.180.187.169 with SMTP id ft9mr2433971wic.14.1380804668225; Thu, 03 Oct 2013 05:51:08 -0700 (PDT) Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by mx.google.com with ESMTPS id j9si2922873wiy.36.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 05:51:08 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.41 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=74.125.82.41; Received: by mail-wg0-f41.google.com with SMTP id l18so665771wgh.2 for ; Thu, 03 Oct 2013 05:51:07 -0700 (PDT) X-Received: by 10.194.22.97 with SMTP id c1mr1930509wjf.43.1380804667661; Thu, 03 Oct 2013 05:51:07 -0700 (PDT) Received: from localhost.localdomain (cpc6-seac21-2-0-cust453.7-2.cable.virginmedia.com. [82.1.113.198]) by mx.google.com with ESMTPSA id l9sm26541924wif.10.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 03 Oct 2013 05:51:06 -0700 (PDT) Message-ID: <524D6838.5080607@linaro.org> Date: Thu, 03 Oct 2013 13:51:04 +0100 From: Will Newton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: qemu-devel@nongnu.org CC: patches@linaro.org Subject: [PATCH v2] target-arm: Implement ARMv8 VSEL instruction. X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This adds support for the VSEL floating point selection instruction which was added in ARMv8. It is based on the previous patch[1] from Mans Rullgard, but attempts to address the feedback given on that patch. [1] http://lists.nongnu.org/archive/html/qemu-devel/2013-06/msg03117.html Signed-off-by: Will Newton --- target-arm/translate.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) Changes in v2: - Integrate vsel decoding into disas_vfp_insn diff --git a/target-arm/translate.c b/target-arm/translate.c index 998bde2..5e49334 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -2880,6 +2880,98 @@ static int disas_vfp_insn(CPUARMState * env, DisasContext *s, uint32_t insn) rm = VFP_SREG_M(insn); } + if ((insn & 0x0f800e50) == 0x0e000a00) { + /* vsel */ + uint32_t cc = (insn >> 20) & 3; + TCGv_i32 tmp, zero; + + /* ARMv8 VFP. */ + if (!arm_feature(env, ARM_FEATURE_V8)) + return 1; + + zero = tcg_const_tl(0); + + if (dp) { + TCGv_i64 ftmp1, ftmp2, ftmp3; + + ftmp1 = tcg_temp_new_i64(); + ftmp2 = tcg_temp_new_i64(); + ftmp3 = tcg_temp_new_i64(); + tcg_gen_ld_f64(ftmp1, cpu_env, vfp_reg_offset(dp, rn)); + tcg_gen_ld_f64(ftmp2, cpu_env, vfp_reg_offset(dp, rm)); + switch (cc) { + case 0: /* eq: Z */ + tcg_gen_movcond_i64(TCG_COND_EQ, ftmp3, cpu_ZF, zero, + ftmp1, ftmp2); + break; + case 1: /* vs: V */ + tcg_gen_movcond_i64(TCG_COND_LT, ftmp3, cpu_VF, zero, + ftmp1, ftmp2); + break; + case 2: /* ge: N == V -> N ^ V == 0 */ + tmp = tcg_temp_new_i32(); + tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); + tcg_gen_movcond_i64(TCG_COND_GE, ftmp3, tmp, zero, + ftmp1, ftmp2); + tcg_temp_free_i32(tmp); + break; + case 3: /* gt: !Z && N == V */ + tcg_gen_movcond_i64(TCG_COND_NE, ftmp3, cpu_ZF, zero, + ftmp1, ftmp2); + tmp = tcg_temp_new_i32(); + tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); + tcg_gen_movcond_i64(TCG_COND_GE, ftmp3, tmp, zero, + ftmp3, ftmp2); + tcg_temp_free_i32(tmp); + break; + } + tcg_gen_st_f64(ftmp3, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i64(ftmp1); + tcg_temp_free_i64(ftmp2); + tcg_temp_free_i64(ftmp3); + } else { + TCGv_i32 ftmp1, ftmp2, ftmp3; + + ftmp1 = tcg_temp_new_i32(); + ftmp2 = tcg_temp_new_i32(); + ftmp3 = tcg_temp_new_i32(); + tcg_gen_ld_f32(ftmp1, cpu_env, vfp_reg_offset(dp, rn)); + tcg_gen_ld_f32(ftmp2, cpu_env, vfp_reg_offset(dp, rm)); + switch (cc) { + case 0: /* eq: Z */ + tcg_gen_movcond_i32(TCG_COND_EQ, ftmp3, cpu_ZF, zero, + ftmp1, ftmp2); + break; + case 1: /* vs: V */ + tcg_gen_movcond_i32(TCG_COND_LT, ftmp3, cpu_VF, zero, + ftmp1, ftmp2); + break; + case 2: /* ge: N == V -> N ^ V == 0 */ + tmp = tcg_temp_new_i32(); + tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); + tcg_gen_movcond_i32(TCG_COND_GE, ftmp3, tmp, zero, + ftmp1, ftmp2); + tcg_temp_free_i32(tmp); + break; + case 3: /* gt: !Z && N == V */ + tcg_gen_movcond_i32(TCG_COND_NE, ftmp3, cpu_ZF, zero, + ftmp1, ftmp2); + tmp = tcg_temp_new_i32(); + tcg_gen_xor_i32(tmp, cpu_VF, cpu_NF); + tcg_gen_movcond_i32(TCG_COND_GE, ftmp3, tmp, zero, + ftmp3, ftmp2); + tcg_temp_free_i32(tmp); + break; + } + tcg_gen_st_f32(ftmp3, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i32(ftmp1); + tcg_temp_free_i32(ftmp2); + tcg_temp_free_i32(ftmp3); + } + + return 0; + } + veclen = s->vec_len; if (op == 15 && rn > 3) veclen = 0; @@ -6756,6 +6848,13 @@ static void disas_arm_insn(CPUARMState * env, DisasContext *s) goto illegal_op; return; } + if ((insn & 0x0f800e50) == 0x0e000a00) { + /* ARMv8 VFP. */ + ARCH(8); + + if (disas_vfp_insn(env, s, insn)) + goto illegal_op; + } if (((insn & 0x0f30f000) == 0x0510f000) || ((insn & 0x0f30f010) == 0x0710f000)) { if ((insn & (1 << 22)) == 0) { @@ -8768,6 +8867,12 @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28); if (disas_neon_data_insn(env, s, insn)) goto illegal_op; + } else if ((insn & 0x0f800e50) == 0x0e000a00) { + /* ARMv8 VFP. */ + ARCH(8); + + if (disas_vfp_insn(env, s, insn)) + goto illegal_op; } else { if (insn & (1 << 28)) goto illegal_op;