From patchwork Tue Jan 28 11:22:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 23785 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 91549202FA for ; Tue, 28 Jan 2014 11:22:57 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id fa1sf510909pad.0 for ; Tue, 28 Jan 2014 03:22:56 -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=5h7fQLJvynTr73BO5DUrBzJVunYVKe8OpnRzDM+pAp4=; b=bR3qnnZGUfGXCiM9nXLPWu6SJFPJIHwUnwxav2klB1vzA0wr5zKJVkzFDWMzSlDPB0 8xvd92dN9neHvD9ZVU5G7ab/skvlMGYC4iwzepH958VHUOw76B2fRYXfWKM8SVVzpfT8 IfB8WOdOZZsDpg7XVWNxgxFgj5evvdOinmNLNONMp01W3KEiTeVE5MNpJOEGEe4c9Q51 TVCBm/lOGK91LYtZ4VlVkcpuS27yddiMGke2T7F0jnLsqXzmrU53AhyKS38KaM0Zi/vT MfyLvsoHN+Gmxk/u6HdE3aE3GmVnDt9Lqs02lMCzUHEy4651k7KlM8SKWQcabBwjwQqp 1VNA== X-Gm-Message-State: ALoCoQk5H7BixikohUvjVz4bFyhWDiG8ISpwr1sGegdRaxD7137uXfkc4TTuUYxj0cmOROgCNbkP X-Received: by 10.66.163.67 with SMTP id yg3mr314193pab.45.1390908176873; Tue, 28 Jan 2014 03:22:56 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.35.208 with SMTP id n74ls1840559qgn.65.gmail; Tue, 28 Jan 2014 03:22:56 -0800 (PST) X-Received: by 10.220.106.84 with SMTP id w20mr619013vco.18.1390908176761; Tue, 28 Jan 2014 03:22:56 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id cy15si6253032veb.30.2014.01.28.03.22.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Jan 2014 03:22:56 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 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.173; Received: by mail-ve0-f173.google.com with SMTP id oz11so149275veb.4 for ; Tue, 28 Jan 2014 03:22:56 -0800 (PST) X-Received: by 10.220.58.202 with SMTP id i10mr585962vch.23.1390908176694; Tue, 28 Jan 2014 03:22:56 -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 u4csp22925vcz; Tue, 28 Jan 2014 03:22:56 -0800 (PST) X-Received: by 10.152.170.135 with SMTP id am7mr577311lac.23.1390908176022; Tue, 28 Jan 2014 03:22:56 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com [209.85.217.170]) by mx.google.com with ESMTPS id 1si6622359laj.171.2014.01.28.03.22.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Jan 2014 03:22:55 -0800 (PST) Received-SPF: neutral (google.com: 209.85.217.170 is neither permitted nor denied by best guess record for domain of will.newton@linaro.org) client-ip=209.85.217.170; Received: by mail-lb0-f170.google.com with SMTP id u14so202275lbd.1 for ; Tue, 28 Jan 2014 03:22:55 -0800 (PST) X-Received: by 10.152.180.4 with SMTP id dk4mr46499lac.49.1390908175338; Tue, 28 Jan 2014 03:22:55 -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.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2014 03:22:54 -0800 (PST) From: Will Newton To: qemu-devel@nongnu.org Cc: Peter Maydell , patches@linaro.org Subject: [PATCH v2 09/11] target-arm: Add AArch32 FP VCVTA, VCVTN, VCVTP and VCVTM Date: Tue, 28 Jan 2014 11:22:33 +0000 Message-Id: <1390908155-23475-9-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.173 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 the AArch32 floating-point VCVTA, VCVTN, VCVTP and VCVTM instructions. Signed-off-by: Will Newton --- target-arm/translate.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/target-arm/translate.c b/target-arm/translate.c index 5a8ca24..0fcc159 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -2797,6 +2797,63 @@ static int handle_vrint(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, return 0; } +static int handle_vcvt(uint32_t insn, uint32_t rd, uint32_t rm, uint32_t dp, + int rounding) +{ + bool is_signed = extract32(insn, 7, 1); + TCGv_ptr fpst = get_fpstatus_ptr(0); + TCGv_i32 tcg_rmode, tcg_shift; + + tcg_shift = tcg_const_i32(0); + + 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_double, tcg_res; + TCGv_i32 tcg_tmp; + /* Rd is encoded as a single precision register even when the source + * is double precision. + */ + rd = ((rd << 1) & 0x1e) | ((rd >> 4) & 0x1); + tcg_double = tcg_temp_new_i64(); + tcg_res = tcg_temp_new_i64(); + tcg_tmp = tcg_temp_new_i32(); + tcg_gen_ld_f64(tcg_double, cpu_env, vfp_reg_offset(1, rm)); + if (is_signed) { + gen_helper_vfp_tosld(tcg_res, tcg_double, tcg_shift, fpst); + } else { + gen_helper_vfp_tould(tcg_res, tcg_double, tcg_shift, fpst); + } + tcg_gen_trunc_i64_i32(tcg_tmp, tcg_res); + tcg_gen_st_f32(tcg_tmp, cpu_env, vfp_reg_offset(0, rd)); + tcg_temp_free_i32(tcg_tmp); + tcg_temp_free_i64(tcg_res); + tcg_temp_free_i64(tcg_double); + } else { + TCGv_i32 tcg_single, tcg_res; + tcg_single = tcg_temp_new_i32(); + tcg_res = tcg_temp_new_i32(); + tcg_gen_ld_f32(tcg_single, cpu_env, vfp_reg_offset(0, rm)); + if (is_signed) { + gen_helper_vfp_tosls(tcg_res, tcg_single, tcg_shift, fpst); + } else { + gen_helper_vfp_touls(tcg_res, tcg_single, tcg_shift, fpst); + } + tcg_gen_st_f32(tcg_res, cpu_env, vfp_reg_offset(0, rd)); + tcg_temp_free_i32(tcg_res); + tcg_temp_free_i32(tcg_single); + } + + gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); + tcg_temp_free_i32(tcg_rmode); + + tcg_temp_free_i32(tcg_shift); + + 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 @@ -2835,6 +2892,10 @@ static int disas_vfp_v8_insn(CPUARMState *env, DisasContext *s, uint32_t insn) /* VRINTA, VRINTN, VRINTP, VRINTM */ int rounding = fp_decode_rm[extract32(insn, 16, 2)]; return handle_vrint(insn, rd, rm, dp, rounding); + } else if ((insn & 0x0fbc0e50) == 0x0ebc0a40) { + /* VCVTA, VCVTN, VCVTP, VCVTM */ + int rounding = fp_decode_rm[extract32(insn, 16, 2)]; + return handle_vcvt(insn, rd, rm, dp, rounding); } return 1; }