From patchwork Tue Aug 14 00:26:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 144064 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3689559ljj; Mon, 13 Aug 2018 17:27:30 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwHFnkEQhGbB6hAGBXf0Tf5QiEd0f2sUAoclIUl64h4eavaDEPDgQr4XiZBYE2qnojIfF/c X-Received: by 2002:aed:3c34:: with SMTP id t49-v6mr18087050qte.404.1534206450892; Mon, 13 Aug 2018 17:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534206450; cv=none; d=google.com; s=arc-20160816; b=Q7n+veBQgPnCufhmn4aAhllgjesFo5a8mPP2UOQsmRjxRYxh+Zb0s+DIVYe+dXpmwB 9zVJsGqDxTn0/gXB7FI1ozkwvbHfld/SiinyylClKaEtgrvEZiUEZc+p5HKqt+A/jZ08 bpzaoarR/KsnqEpO4BLGl515YKFQ+kdZ8Wl++suQfJJKJ5l0iWSl4D1D4MiKNzlyyJRh 8XECXiii98rYN8fmmDuIIvouizD6FDo+GfUUBhAzzIIJ3fNgS1gFgAQpH/EWtBKPPNhg WBeRKAad0vfoNDs5MiqT1T7X6BxTD6ELsViNoaZJdkYWye1qvLuMl3STeL2/cVFeS/GJ swWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=FsfX1H1P09zN5YuN9E7d+yIJbDJFVwowhQcrFqKWv7Y=; b=pGdaIAjC94AiSUIgcIVTf7B07ZTWcqAMudud/R2OiRjADZzvX5wl/oT1MxZFCIBjGa coMdHxnZYdzynyvYe2eoJjqI+bT6y9XKPtYitbjQwiC9adPTZCBt/QbNHwBg59Ix7+Kn O2qN2HDntv+G0Agh0zOnW7n9cYE/EjfjFghlJC+6/YaBFmfwAeOdaogGQ7WePYcUZOoM iICfHkJkKYfh/+rym3onet8hToYvbzFpkV58fRxRkTyIXttzOA6F7IR/jaXwyrPKIo8m EODfgR3rCktXkYROkSjCA45tIV/WCPVUv2C3tA7+a92JtuVlpfsLfiCRP+DUvCJMzGin ZYFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OfVLEVlS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 46-v6si5575788qtv.342.2018.08.13.17.27.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 13 Aug 2018 17:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OfVLEVlS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpNBK-0004xZ-AW for patch@linaro.org; Mon, 13 Aug 2018 20:27:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fpNAu-0004vk-IS for qemu-devel@nongnu.org; Mon, 13 Aug 2018 20:27:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fpNAt-0000pI-Dd for qemu-devel@nongnu.org; Mon, 13 Aug 2018 20:27:04 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:44848) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fpNAt-0000ou-4d for qemu-devel@nongnu.org; Mon, 13 Aug 2018 20:27:03 -0400 Received: by mail-pg1-x52b.google.com with SMTP id r1-v6so8272987pgp.11 for ; Mon, 13 Aug 2018 17:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FsfX1H1P09zN5YuN9E7d+yIJbDJFVwowhQcrFqKWv7Y=; b=OfVLEVlSt5dG4GTIjlTZdjq45/2TYvg4psrXFov3cxzuLqqJN1QWejz16F4gLyvUsd RHiOpYpHQJTY/nZJ2u4ZWP0aa4GIUMNbcC9XA2SUpD0oaRWcXqKTOp9eDNcMcQqUewnd eZubRuG0pCFhDBNbCfR6IkH3vf7Z8XK+DCa8w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FsfX1H1P09zN5YuN9E7d+yIJbDJFVwowhQcrFqKWv7Y=; b=hIjBlGThjerFg6aDlOS5Qk5zGyv2O3MsaSYhVkg+UhVu3n4Xb8t2uRXR5kbLprpmzU koJMGWTW7n0gctGpbfGYmi6eQkEEyb1/Qr4jdq3ALTTehqpkH2PzEg5WszvS5cqfxWIp lazrf4h57vo0FQAzGOMTytGw/8zzFqo3/DoPvQ1vAzUyJTEMrTpPtfFLYNHjhCcrB+6G mLh+4oCRoMrkOJ4E2xiOMCOZmYCE8n4d7i/bscxGgmjosvoFrn4jLBYfo8TOZc64876T XejF0W/+QZABi+6BwaWHHl3TLWfrHD/hHIZ40K8GyNint3TeldblfOeJ+m4Za1O01r1r tOEg== X-Gm-Message-State: AOUpUlE6musHRFr5l/N5dMA5PS1q5vgOunaAXRq5+0z99QWOtpz2f9hg RvvJwHGwnBhrcDHKNE2tC7aN3qctHl4= X-Received: by 2002:a62:1f06:: with SMTP id f6-v6mr21250386pff.140.1534206421761; Mon, 13 Aug 2018 17:27:01 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id w192-v6sm22266976pfd.74.2018.08.13.17.27.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Aug 2018 17:27:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 13 Aug 2018 17:26:53 -0700 Message-Id: <20180814002653.12828-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180814002653.12828-1-richard.henderson@linaro.org> References: <20180814002653.12828-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52b Subject: [Qemu-devel] [PATCH 4/4] target/arm: Use the float-to-int-scale softfloat routines 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.desnogues@gmail.com, peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/helper.c | 101 ++++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 50 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 38439a2ee8..e4a7d97805 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11552,38 +11552,28 @@ float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \ void *fpstp) \ { return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); } -/* Notice that we want only input-denormal exception flags from the - * scalbn operation: the other possible flags (overflow+inexact if - * we overflow to infinity, output-denormal) aren't correct for the - * complete scale-and-convert operation. - */ -#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, round) \ -uint##isz##_t HELPER(vfp_to##name##p##round)(float##fsz x, \ - uint32_t shift, \ - void *fpstp) \ -{ \ - float_status *fpst = fpstp; \ - int old_exc_flags = get_float_exception_flags(fpst); \ - float##fsz tmp; \ - if (float##fsz##_is_any_nan(x)) { \ - float_raise(float_flag_invalid, fpst); \ - return 0; \ - } \ - tmp = float##fsz##_scalbn(x, shift, fpst); \ - old_exc_flags |= get_float_exception_flags(fpst) \ - & float_flag_input_denormal; \ - set_float_exception_flags(old_exc_flags, fpst); \ - return float##fsz##_to_##itype##round(tmp, fpst); \ +#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, ROUND, suff) \ +uint##isz##_t HELPER(vfp_to##name##p##suff)(float##fsz x, uint32_t shift, \ + void *fpst) \ +{ \ + if (unlikely(float##fsz##_is_any_nan(x))) { \ + float_raise(float_flag_invalid, fpst); \ + return 0; \ + } \ + return float##fsz##_to_##itype##_scalbn(x, ROUND, shift, fpst); \ } #define VFP_CONV_FIX(name, p, fsz, isz, itype) \ VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ -VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, _round_to_zero) \ -VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, ) +VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ + float_round_to_zero, _round_to_zero) \ +VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ + get_float_rounding_mode(fpst), ) #define VFP_CONV_FIX_A64(name, p, fsz, isz, itype) \ VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ -VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, ) +VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ + get_float_rounding_mode(fpst), ) VFP_CONV_FIX(sh, d, 64, 64, int16) VFP_CONV_FIX(sl, d, 64, 64, int32) @@ -11623,53 +11613,64 @@ uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) return uint64_to_float16_scalbn(x, -shift, fpst); } -static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) -{ - if (unlikely(float16_is_any_nan(f))) { - float_raise(float_flag_invalid, fpst); - return 0; - } else { - int old_exc_flags = get_float_exception_flags(fpst); - float64 ret; - - ret = float16_to_float64(f, true, fpst); - ret = float64_scalbn(ret, shift, fpst); - old_exc_flags |= get_float_exception_flags(fpst) - & float_flag_input_denormal; - set_float_exception_flags(old_exc_flags, fpst); - - return ret; - } -} - uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst) { - return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst); + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_int16_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); } uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst) { - return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_uint16_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); } uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst) { - return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst); + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_int32_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); } uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst) { - return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst); + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_uint32_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); } uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst) { - return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst); + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_int64_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); } uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst) { - return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst); + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_uint64_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); } /* Set the current fp rounding mode and return the old one.