From patchwork Mon May 14 22:12:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135779 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp200033lji; Mon, 14 May 2018 15:30:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpzPEhAXM6u1HIZC1uv0P8A7SWuWNozQluw3sZz5DR9cA2EE5HX89pjlFX9Aadi4pRlIIBw X-Received: by 2002:a0c:a94c:: with SMTP id z12-v6mr10803590qva.57.1526337045979; Mon, 14 May 2018 15:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526337045; cv=none; d=google.com; s=arc-20160816; b=IXwyiKJh6g8BTudZvKGDfJ4Pc5Emit2HLI3mwjZb4E6HwhcBnw0ZU1DCkpewHrTLBW xWn1zhueJCl/oCxjXCz/xTyD43AqFDJJRVRG9T7gjGG8J0j53xBFNsN8/Rm/2ecjFKIC QCVCJCPyfHEnQ21nhGmfOMJTsNBjEK1J3kueA/aJTp9PnlxN/7W53HBLnDurz717b67o Twuum8sKnQ+YR7A1inf1CS0u5qTK4uDBaOzcNEJOd4mT3xDTqz0IyFlw68nVbIUfA3+b 5JkPI6kb0CnwFIOmBBP2N4hyrOJIJ+BAas59Y8gHfXkM88oqJ2rKQs4/vnhkVGYsTdqg 1Dbg== 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=6WuZ9p/7jNL+hLMOjd4yPOus0eQnm6/8jO4I9mebAGw=; b=dnNNCY5sEDyDoJuE35QzcPIxTJjHFy87nD2nJgS3Tq2KlgtovnyyRKOH0MYs0HR8Bw Ao7hI5Sv+2V+4t9y7yqUMmJocnT4nNX2iZpl2JLXsVYJCFyscSz2VaB4+3jOLCqmnmXu L+fiMyMDDHD3AYtdC8Ype+PeJurnaglsoSAb4/NoRrz6/y/CcYYm9b8jFFlwMLdnt69H U37bHBPSJX4SayG7tvXPZccf08B0ZJFSq/ppzLNjSbChmWXOcIUWvIsR1im6iT0JksLk PUSU54HcNM2IK7OXSeK5hmvjFjhvfzlQ1IcIz2VrN+gIAozxKM5cLdqsJo53YLV+wlaI XwmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YWW+5kIx; 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 z132-v6si1871914qkz.36.2018.05.14.15.30.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 14 May 2018 15:30:45 -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=YWW+5kIx; 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]:49983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILzR-0005on-Bc for patch@linaro.org; Mon, 14 May 2018 18:30:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fILiF-0008GF-5f for qemu-devel@nongnu.org; Mon, 14 May 2018 18:13:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fILiD-0008Vn-M1 for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:59 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:40810) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fILiD-0008Tl-Dy for qemu-devel@nongnu.org; Mon, 14 May 2018 18:12:57 -0400 Received: by mail-pf0-x242.google.com with SMTP id f189-v6so6668320pfa.7 for ; Mon, 14 May 2018 15:12:57 -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=6WuZ9p/7jNL+hLMOjd4yPOus0eQnm6/8jO4I9mebAGw=; b=YWW+5kIxaZXUUKq4PgJcLnv9QX1aexikvnpfJyULyC/kLpA0MvcYNlcpbG3wTYRR8l S7+YtUumN3VLQ0LYzRFME3js9X34rXlwO9SMwoWe1YRBu9RDHNxFQk1ILiwpxj89bf8h L692iDCQrhDQWNwCtdogUUA2kwW0C5oSlDr/0= 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=6WuZ9p/7jNL+hLMOjd4yPOus0eQnm6/8jO4I9mebAGw=; b=mVh0/I9j8E0sAj3sOuNfw83lFZR+AI65YjaFlx3hxWVHF2XTc5jUWFvx/kWf6Cq6s3 y7wMYNpyUY9Ml0xr4BFqqzvd57w47fY1XskxYv2AeO9toq2LTN8lERBbLB3UESSltu3F 3mEAsMoLoc83DxiCztmwa3W2+wb6TpFAlzzf8Iey1womZ4zlLq6fNxz5FBovP+U4AR1m u9jbHtAx9bJxZy4SmH8B/+gNS4a7OtbrKhT+ndEOCAuPg8df+HIHTkaUuVH4aUBFnRpM DFP/qU6A6/XZZzxf7MzEm5vofsg6V5cTJZCxrLBZDG5SeBbSqzZOLWMIMfBdJ743Rc+k LOYg== X-Gm-Message-State: ALKqPwf1rLXWA+Wfl2+OB6FrUYoMipIFDOdSBWXr58MB4EiTpZ0/Xa6r /2xoYpiLy/7Mcvuv8VmhYrcZwfmezC8= X-Received: by 2002:a63:8849:: with SMTP id l70-v6mr10027306pgd.49.1526335976103; Mon, 14 May 2018 15:12:56 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id y2-v6sm14512457pgp.92.2018.05.14.15.12.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 15:12:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 15:12:16 -0700 Message-Id: <20180514221219.7091-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514221219.7091-1-richard.henderson@linaro.org> References: <20180514221219.7091-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v5 25/28] fpu/softfloat: Pass FloatClass to pickNaNMulAdd 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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For each operand, pass a single enumeration instead of a pair of booleans. The commit also merges multiple different ifdef-selected implementations of pickNaNMulAdd into a single function whose body is ifdef-selected. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- fpu/softfloat-specialize.h | 70 +++++++++++++++----------------------- fpu/softfloat.c | 5 +-- 2 files changed, 28 insertions(+), 47 deletions(-) -- 2.17.0 diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h index 2695183188..0399dfe011 100644 --- a/fpu/softfloat-specialize.h +++ b/fpu/softfloat-specialize.h @@ -594,15 +594,14 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | information. | Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN *----------------------------------------------------------------------------*/ -#if defined(TARGET_ARM) -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) +static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, + bool infzero, float_status *status) { +#if defined(TARGET_ARM) /* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns * the default NaN */ - if (infzero && cIsQNaN) { + if (infzero && is_qnan(c_cls)) { float_raise(float_flag_invalid, status); return 3; } @@ -610,25 +609,20 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, /* This looks different from the ARM ARM pseudocode, because the ARM ARM * puts the operands to a fused mac operation (a*b)+c in the order c,a,b. */ - if (cIsSNaN) { + if (is_snan(c_cls)) { return 2; - } else if (aIsSNaN) { + } else if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (cIsQNaN) { + } else if (is_qnan(c_cls)) { return 2; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; } else { return 1; } -} #elif defined(TARGET_MIPS) -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) -{ /* For MIPS, the (inf,zero,qnan) case sets InvalidOp and returns * the default NaN */ @@ -639,41 +633,36 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, if (snan_bit_is_one(status)) { /* Prefer sNaN over qNaN, in the a, b, c order. */ - if (aIsSNaN) { + if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (cIsSNaN) { + } else if (is_snan(c_cls)) { return 2; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; - } else if (bIsQNaN) { + } else if (is_qnan(b_cls)) { return 1; } else { return 2; } } else { /* Prefer sNaN over qNaN, in the c, a, b order. */ - if (cIsSNaN) { + if (is_snan(c_cls)) { return 2; - } else if (aIsSNaN) { + } else if (is_snan(a_cls)) { return 0; - } else if (bIsSNaN) { + } else if (is_snan(b_cls)) { return 1; - } else if (cIsQNaN) { + } else if (is_qnan(c_cls)) { return 2; - } else if (aIsQNaN) { + } else if (is_qnan(a_cls)) { return 0; } else { return 1; } } -} #elif defined(TARGET_PPC) -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) -{ /* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer * to return an input NaN if we have one (ie c) rather than generating * a default NaN @@ -686,31 +675,26 @@ static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, /* If fRA is a NaN return it; otherwise if fRB is a NaN return it; * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB */ - if (aIsSNaN || aIsQNaN) { + if (is_nan(a_cls)) { return 0; - } else if (cIsSNaN || cIsQNaN) { + } else if (is_nan(c_cls)) { return 2; } else { return 1; } -} #else -/* A default implementation: prefer a to b to c. - * This is unlikely to actually match any real implementation. - */ -static int pickNaNMulAdd(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, - flag cIsQNaN, flag cIsSNaN, flag infzero, - float_status *status) -{ - if (aIsSNaN || aIsQNaN) { + /* A default implementation: prefer a to b to c. + * This is unlikely to actually match any real implementation. + */ + if (is_nan(a_cls)) { return 0; - } else if (bIsSNaN || bIsQNaN) { + } else if (is_nan(b_cls)) { return 1; } else { return 2; } -} #endif +} /*---------------------------------------------------------------------------- | Takes two single-precision floating-point values `a' and `b', one of which diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 43264fa1f6..65e970eeb2 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -601,10 +601,7 @@ static FloatParts pick_nan_muladd(FloatParts a, FloatParts b, FloatParts c, s->float_exception_flags |= float_flag_invalid; } - which = pickNaNMulAdd(is_qnan(a.cls), is_snan(a.cls), - is_qnan(b.cls), is_snan(b.cls), - is_qnan(c.cls), is_snan(c.cls), - inf_zero, s); + which = pickNaNMulAdd(a.cls, b.cls, c.cls, inf_zero, s); if (s->default_nan_mode) { /* Note that this check is after pickNaNMulAdd so that function