From patchwork Tue May 15 22:25:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135943 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp81759lji; Tue, 15 May 2018 15:35:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZov21R3uTqX/OmRXVJTegHWSKwborhXCTlO+S14a8zA6GlNrCHpf+e/hS9T2PDybRZQB2Lb X-Received: by 2002:ac8:6d2:: with SMTP id j18-v6mr15292280qth.306.1526423720495; Tue, 15 May 2018 15:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526423720; cv=none; d=google.com; s=arc-20160816; b=gWvVIzwaWMlXvXfYAlJDrIhf6jFcvxS2IIYu2/4BmJoIxGjioOLHjr98Aabv0YlSDz dcH5Vh2ZIfYgDPNv5F6R9b4p/G4HEzHiO4OU8aH+OIxX+9Pv2OY/Q6rdVB7oj5sqKMjh 9VJbR8lkH4Xh2KAMzGGZhTXY1xZEOrEHoxALBKEmyyua84fAim1XolpD2fX3x6C4dtEz djirByqjXz1VZcuHahUBV7fhQzo0o0TyL/WTp50j5bdjHvQtdvemOnhss/nZwbeYRObc DKfFYg2/ipXlUGx4WD2gwctxjPl80adoHu0LiryvmE+kSttq5EM9TDrrfXERbi8cZQVr Kjwg== 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=Km/+APAHOTa+3ERJ5Q07DMLbXDW6tlSNA1trH1+jvLU=; b=g4lFNvTqYy67KKBI/BdgBbqdK2vY/JuVj4LJ/L4BF4DclRzbKM3Zm3OEyJGotx032S B5vC77I+camMKe2ooYywWxBktjeWRpSnDiyc4l4oAcD6zWEjcDUDck0iRMN2feFeREJc UYLiPkMywiNzbUywEp1MTzEkZjEdUY4d7SLQDA4jJMlca4SPRxxVaXGZNGmQYIF8f8AB isezuaT4KIsvGMbKNTUyXgltEHSwutr/Wl4PijQwhCO99JlA2WL4jYDLvnUpgzWwLNy3 +dFy3p4Tgddr3E4dZBCjLQreksaiVXyeDxOIjFdm4LGkfo1PA1TsySUvT9eRCHaIxO8o eStQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LsRIqkB3; 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 r66-v6si1181896qkh.314.2018.05.15.15.35.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 15 May 2018 15:35:20 -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=LsRIqkB3; 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]:36349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIiXP-0000YG-SG for patch@linaro.org; Tue, 15 May 2018 18:35:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIiOl-0003ky-Cg for qemu-devel@nongnu.org; Tue, 15 May 2018 18:26:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIiOi-0008MA-Qs for qemu-devel@nongnu.org; Tue, 15 May 2018 18:26:23 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:39648) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIiOi-0008GI-Eq for qemu-devel@nongnu.org; Tue, 15 May 2018 18:26:20 -0400 Received: by mail-pf0-x244.google.com with SMTP id a22-v6so736580pfn.6 for ; Tue, 15 May 2018 15:26:20 -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=Km/+APAHOTa+3ERJ5Q07DMLbXDW6tlSNA1trH1+jvLU=; b=LsRIqkB3yY3wVH2rqU72vl8SPgpIB34DRbFinY4lKxi4/AHiyqgDBsNlyMKSZ8fFXF wGwdgNBQTj7sAHqvASqgMQVaPOdMBu7KAG6LHrFJ0mJ4uj8LW2WLRnoOOEJ8uGuGzL6q Iw8oKdQ4f0gVKYOzhZykuvJlfF6uQ0sN12esY= 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=Km/+APAHOTa+3ERJ5Q07DMLbXDW6tlSNA1trH1+jvLU=; b=M/NqePcLA1mNwkziXoA6JpAsZK857rqQm12qdO5h+lkof3djwKJ+JRTZRdcwcwbvyg AUtKPaG7JSKNY7NXpB8kNhduuaH4M4+fbJBvnBxNp3J1x6pDfS//+hijG9j/z9htC+Ea 0QEzJ24XnMsEZd0cagArQHe0gslAPPDN1q+iyTcLfeUG2MooYPn/JESjPpiOlAJKE/2G aw0oJU2lGTfcAGi9/8Efi3ShnoVu74nZxGsm+0PJrFDJS3a3M056zrUFDUB+XL6R7hX8 dZz6+lzV74/2TzgnforiChpfE1QbgMNlGO9B+ymNBclgnDzFGvqiKCS4rgxeHGUrrPT7 rUdA== X-Gm-Message-State: ALKqPwc5Nzy4lKXkTR1Qenr6qWWueX3QAm9O6Voujbaxq+iclbUSQVeY 82ZlGSahO76EqPiEMvxszgYIvCray8A= X-Received: by 2002:a62:5841:: with SMTP id m62-v6mr16803537pfb.116.1526423179092; Tue, 15 May 2018 15:26:19 -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 g11-v6sm941419pgq.62.2018.05.15.15.26.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 15:26:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 15:25:37 -0700 Message-Id: <20180515222540.9988-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180515222540.9988-1-richard.henderson@linaro.org> References: <20180515222540.9988-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::244 Subject: [Qemu-devel] [PATCH v6 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 55954385ff..8e97602ace 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