From patchwork Tue Jan 28 11:22:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 23778 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A0A51202FA for ; Tue, 28 Jan 2014 11:22:46 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id w20sf484873vbb.7 for ; Tue, 28 Jan 2014 03:22:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=GZ/HZro8KH1vRmBearOeAfglyLfx3jdz0cdX4WmAC/Q=; b=TWFlPhqT63nS4We/nrORIApbCoaBf9M1VV1h6Ll5Hcop1j8abqrqfmkAxhNrFhiIpM rpR+JD0UYgWSy1FOX4QnugxLUe1iU/U5GPgTA4DaJXf9fmAVyGd7oAfQLzxszf7haGgP NEFycL/V/2IFMn2uv5rAmATHMVR2fnFAw5JUpLfSNeVD0ebfhxSH4AC89Lm9RMir+MNv O92zIC8F0I/wEFPLbNW5bfzmVfwc88E6s9WMBdWB4WrZeXUVVm+n/23o/qDGsLIpbAA8 s6IACPrTwLxA+79n9ohRkYZMNesMabl+u53okCwNfmOJ8TinlpSGIeQxa5A0GGEGeOgf sPDg== X-Gm-Message-State: ALoCoQndvXdJBcRiEC7hNeLW1rREKWFOQlRr0mVEBJYrCV5u8TwrQbAJw42x43kcr+fgNqyJCzy1 X-Received: by 10.236.36.39 with SMTP id v27mr282583yha.5.1390908165834; Tue, 28 Jan 2014 03:22:45 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.102 with SMTP id a93ls1814988qga.33.gmail; Tue, 28 Jan 2014 03:22:45 -0800 (PST) X-Received: by 10.53.13.44 with SMTP id ev12mr490930vdd.17.1390908165720; Tue, 28 Jan 2014 03:22:45 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id io9si978825vcb.62.2014.01.28.03.22.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Jan 2014 03:22:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 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.170; Received: by mail-ve0-f170.google.com with SMTP id cz12so158510veb.1 for ; Tue, 28 Jan 2014 03:22:45 -0800 (PST) X-Received: by 10.58.66.137 with SMTP id f9mr584870vet.11.1390908165650; Tue, 28 Jan 2014 03:22:45 -0800 (PST) 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 u4csp22910vcz; Tue, 28 Jan 2014 03:22:45 -0800 (PST) X-Received: by 10.152.44.133 with SMTP id e5mr566430lam.37.1390908163960; Tue, 28 Jan 2014 03:22:43 -0800 (PST) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com [209.85.215.41]) by mx.google.com with ESMTPS id e6si6641286lam.69.2014.01.28.03.22.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Jan 2014 03:22:43 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.41 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=209.85.215.41; Received: by mail-la0-f41.google.com with SMTP id mc6so205472lab.28 for ; Tue, 28 Jan 2014 03:22:43 -0800 (PST) X-Received: by 10.152.87.169 with SMTP id az9mr616640lab.32.1390908163331; Tue, 28 Jan 2014 03:22:43 -0800 (PST) Received: from localhost.localdomain (cpc6-seac21-2-0-cust453.7-2.cable.virginm.net. [82.1.113.198]) by mx.google.com with ESMTPSA id a8sm22366424lae.5.2014.01.28.03.22.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2014 03:22:42 -0800 (PST) From: Will Newton To: qemu-devel@nongnu.org Cc: Peter Maydell , patches@linaro.org Subject: [PATCH v2 02/11] target-arm: Add AArch32 FP VRINTA, VRINTN, VRINTP and VRINTM Date: Tue, 28 Jan 2014 11:22:26 +0000 Message-Id: <1390908155-23475-2-git-send-email-will.newton@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1390908155-23475-1-git-send-email-will.newton@linaro.org> References: <1390908155-23475-1-git-send-email-will.newton@linaro.org> 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.170 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: , Add support for AArch32 ARMv8 FP VRINTA, VRINTN, VRINTP and VRINTM instructions. Signed-off-by: Will Newton --- target-arm/translate.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) Changes in v2: - Add comment to fp_decode_rm lookup table diff --git a/target-arm/translate.c b/target-arm/translate.c index 8d240e1..2db6812 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -2759,6 +2759,56 @@ static int handle_vminmaxnm(uint32_t insn, uint32_t rd, uint32_t rn, return 0; } +static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, + int rounding) +{ + TCGv_ptr fpst = get_fpstatus_ptr(0); + TCGv_i32 tcg_rmode; + + tcg_rmode = tcg_const_i32(arm_rmode_to_sf(rounding)); + gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + + if (dp) { + TCGv_i64 tcg_op; + TCGv_i64 tcg_res; + tcg_op = tcg_temp_new_i64(); + tcg_res = tcg_temp_new_i64(); + tcg_gen_ld_f64(tcg_op, cpu_env, vfp_reg_offset(dp, rm)); + gen_helper_rintd(tcg_res, tcg_op, fpst); + tcg_gen_st_f64(tcg_res, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i64(tcg_op); + tcg_temp_free_i64(tcg_res); + } else { + TCGv_i32 tcg_op; + TCGv_i32 tcg_res; + tcg_op = tcg_temp_new_i32(); + tcg_res = tcg_temp_new_i32(); + tcg_gen_ld_f32(tcg_op, cpu_env, vfp_reg_offset(dp, rm)); + gen_helper_rints(tcg_res, tcg_op, fpst); + tcg_gen_st_f32(tcg_res, cpu_env, vfp_reg_offset(dp, rd)); + tcg_temp_free_i32(tcg_op); + tcg_temp_free_i32(tcg_res); + } + + gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + tcg_temp_free_i32(tcg_rmode); + + tcg_temp_free_ptr(fpst); + return 0; +} + + +/* Table for converting the most common AArch32 encoding of + * rounding mode to arm_fprounding order (which matches the + * common AArch64 order); see ARM ARM pseudocode FPDecodeRM(). + */ +static const uint8_t fp_decode_rm[] = { + FPROUNDING_TIEAWAY, + FPROUNDING_TIEEVEN, + FPROUNDING_POSINF, + FPROUNDING_NEGINF, +}; + static int disas_vfp_v8_insn(CPUARMState *env, DisasContext *s, uint32_t insn) { uint32_t rd, rn, rm, dp = extract32(insn, 8, 1); @@ -2781,6 +2831,10 @@ static int disas_vfp_v8_insn(CPUARMState *env, DisasContext *s, uint32_t insn) return handle_vsel(insn, rd, rn, rm, dp); } else if ((insn & 0x0fb00e10) == 0x0e800a00) { return handle_vminmaxnm(insn, rd, rn, rm, dp); + } else if ((insn & 0x0fbc0ed0) == 0x0eb80a40) { + /* VRINTA, VRINTN, VRINTP, VRINTM */ + int rounding = fp_decode_rm[extract32(insn, 16, 2)]; + return handle_vrint(insn, rd, rm, dp, rounding); } return 1; }