public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Laszlo Ersek <lersek@redhat.com>,
	"Gao, Liming" <liming.gao@intel.com>,
	"Wang, Jian J" <jian.j.wang@intel.com>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Xiaoyu Lu <xiaoyux.lu@intel.com>
Subject: [PATCH v2 2/7] ArmPkg/ArmSoftFloatLib: switch to new version of softfloat library
Date: Mon, 27 May 2019 22:51:36 +0200	[thread overview]
Message-ID: <20190527205141.12344-3-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20190527205141.12344-1-ard.biesheuvel@linaro.org>

Update the INF description and the top level .c files in order to
switch to the new version of the SoftFloat library imported in the
previous patch.

Note that we no longer use the code that travelled a long way from
the 2002 version of the softfloat library via NetBsd and the StdLib
package. Instead, we are using the upstream version unmodified, with
the glue .c file adopted from the OP-TEE project. This approach is
much cleaner and much more maintainable.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1845
Build-tested-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Jian J Wang <jian.j.wang@intel.com>
Tested-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.c                                 | 283 ++++++++++++++++++++
 ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf                               |  84 ++++--
 ArmPkg/Library/ArmSoftFloatLib/SoftFloat-3e/build/Linux-ARM-VFPv2-GCC/platform.h |   2 +-
 3 files changed, 348 insertions(+), 21 deletions(-)

diff --git a/ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.c b/ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.c
new file mode 100644
index 000000000000..42bed7700c99
--- /dev/null
+++ b/ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.c
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2015 - 2019, Linaro Limited
+ *
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
+ */
+
+#include "platform.h"
+#include <softfloat.h>
+
+/*
+ * On ARM32 EABI defines both a soft-float ABI and a hard-float ABI,
+ * hard-float is basically a super set of soft-float. Hard-float requires
+ * all the support routines provided for soft-float, but the compiler may
+ * choose to optimize to not use some of them.
+ *
+ * The AEABI functions uses soft-float calling convention even if the
+ * functions are compiled for hard-float. So where float and double would
+ * have been expected we use aeabi_float_t and aeabi_double_t respectively
+ * instead.
+ */
+typedef uint32_t aeabi_float_t;
+typedef uint64_t aeabi_double_t;
+
+/*
+ * Helpers to convert between float32 and aeabi_float_t, and float64 and
+ * aeabi_double_t used by the AEABI functions below.
+ */
+static aeabi_float_t f32_to_f(float32_t val)
+{
+	return val.v;
+}
+
+static float32_t f32_from_f(aeabi_float_t val)
+{
+	float32_t res;
+
+	res.v = val;
+
+	return res;
+}
+
+static aeabi_double_t f64_to_d(float64_t val)
+{
+	return val.v;
+}
+
+static float64_t f64_from_d(aeabi_double_t val)
+{
+	float64_t res;
+
+	res.v = val;
+
+	return res;
+}
+
+/*
+ * From ARM Run-time ABI for ARM Architecture
+ * ARM IHI 0043D, current through ABI release 2.09
+ *
+ * 4.1.2 The floating-point helper functions
+ */
+
+/*
+ * Table 2, Standard aeabi_double_t precision floating-point arithmetic helper
+ * functions
+ */
+
+aeabi_double_t __aeabi_dadd(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_to_d(f64_add(f64_from_d(a), f64_from_d(b)));
+}
+
+aeabi_double_t __aeabi_ddiv(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_to_d(f64_div(f64_from_d(a), f64_from_d(b)));
+}
+
+aeabi_double_t __aeabi_dmul(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_to_d(f64_mul(f64_from_d(a), f64_from_d(b)));
+}
+
+
+aeabi_double_t __aeabi_drsub(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_to_d(f64_sub(f64_from_d(b), f64_from_d(a)));
+}
+
+aeabi_double_t __aeabi_dsub(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_to_d(f64_sub(f64_from_d(a), f64_from_d(b)));
+}
+
+/*
+ * Table 3, double precision floating-point comparison helper functions
+ */
+
+int __aeabi_dcmpeq(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_eq(f64_from_d(a), f64_from_d(b));
+}
+
+int __aeabi_dcmplt(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_lt(f64_from_d(a), f64_from_d(b));
+}
+
+int __aeabi_dcmple(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_le(f64_from_d(a), f64_from_d(b));
+}
+
+int __aeabi_dcmpge(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_le(f64_from_d(b), f64_from_d(a));
+}
+
+int __aeabi_dcmpgt(aeabi_double_t a, aeabi_double_t b)
+{
+	return f64_lt(f64_from_d(b), f64_from_d(a));
+}
+
+/*
+ * Table 4, Standard single precision floating-point arithmetic helper
+ * functions
+ */
+
+aeabi_float_t __aeabi_fadd(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_to_f(f32_add(f32_from_f(a), f32_from_f(b)));
+}
+
+aeabi_float_t __aeabi_fdiv(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_to_f(f32_div(f32_from_f(a), f32_from_f(b)));
+}
+
+aeabi_float_t __aeabi_fmul(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_to_f(f32_mul(f32_from_f(a), f32_from_f(b)));
+}
+
+aeabi_float_t __aeabi_frsub(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_to_f(f32_sub(f32_from_f(b), f32_from_f(a)));
+}
+
+aeabi_float_t __aeabi_fsub(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_to_f(f32_sub(f32_from_f(a), f32_from_f(b)));
+}
+
+/*
+ * Table 5, Standard single precision floating-point comparison helper
+ * functions
+ */
+
+int __aeabi_fcmpeq(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_eq(f32_from_f(a), f32_from_f(b));
+}
+
+int __aeabi_fcmplt(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_lt(f32_from_f(a), f32_from_f(b));
+}
+
+int __aeabi_fcmple(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_le(f32_from_f(a), f32_from_f(b));
+}
+
+int __aeabi_fcmpge(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_le(f32_from_f(b), f32_from_f(a));
+}
+
+int __aeabi_fcmpgt(aeabi_float_t a, aeabi_float_t b)
+{
+	return f32_lt(f32_from_f(b), f32_from_f(a));
+}
+
+/*
+ * Table 6, Standard floating-point to integer conversions
+ */
+
+int __aeabi_d2iz(aeabi_double_t a)
+{
+	return f64_to_i32_r_minMag(f64_from_d(a), false);
+}
+
+unsigned __aeabi_d2uiz(aeabi_double_t a)
+{
+	return f64_to_ui32_r_minMag(f64_from_d(a), false);
+}
+
+long long __aeabi_d2lz(aeabi_double_t a)
+{
+	return f64_to_i64_r_minMag(f64_from_d(a), false);
+}
+
+unsigned long long __aeabi_d2ulz(aeabi_double_t a)
+{
+	return f64_to_ui64_r_minMag(f64_from_d(a), false);
+}
+
+int __aeabi_f2iz(aeabi_float_t a)
+{
+	return f32_to_i32_r_minMag(f32_from_f(a), false);
+}
+
+unsigned __aeabi_f2uiz(aeabi_float_t a)
+{
+	return f32_to_ui32_r_minMag(f32_from_f(a), false);
+}
+
+long long __aeabi_f2lz(aeabi_float_t a)
+{
+	return f32_to_i64_r_minMag(f32_from_f(a), false);
+}
+
+unsigned long long __aeabi_f2ulz(aeabi_float_t a)
+{
+	return f32_to_ui64_r_minMag(f32_from_f(a), false);
+}
+
+/*
+ * Table 7, Standard conversions between floating types
+ */
+
+aeabi_float_t __aeabi_d2f(aeabi_double_t a)
+{
+	return f32_to_f(f64_to_f32(f64_from_d(a)));
+}
+
+aeabi_double_t __aeabi_f2d(aeabi_float_t a)
+{
+	return f64_to_d(f32_to_f64(f32_from_f(a)));
+}
+
+/*
+ * Table 8, Standard integer to floating-point conversions
+ */
+
+aeabi_double_t __aeabi_i2d(int a)
+{
+	return f64_to_d(i32_to_f64(a));
+}
+
+aeabi_double_t __aeabi_ui2d(unsigned a)
+{
+	return f64_to_d(ui32_to_f64(a));
+}
+
+aeabi_double_t __aeabi_l2d(long long a)
+{
+	return f64_to_d(i64_to_f64(a));
+}
+
+aeabi_double_t __aeabi_ul2d(unsigned long long a)
+{
+	return f64_to_d(ui64_to_f64(a));
+}
+
+aeabi_float_t __aeabi_i2f(int a)
+{
+	return f32_to_f(i32_to_f32(a));
+}
+
+aeabi_float_t __aeabi_ui2f(unsigned a)
+{
+	return f32_to_f(ui32_to_f32(a));
+}
+
+aeabi_float_t __aeabi_l2f(long long a)
+{
+	return f32_to_f(i64_to_f32(a));
+}
+
+aeabi_float_t __aeabi_ul2f(unsigned long long a)
+{
+	return f32_to_f(ui64_to_f32(a));
+}
diff --git a/ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf b/ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
index cbb49f49ade6..7f49608a1592 100644
--- a/ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
+++ b/ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
@@ -2,15 +2,14 @@
 #  ARM Software floating point Library.
 #
 #  Copyright (c) 2014, ARM Ltd. All rights reserved.
-#  Copyright (c) 2015, Linaro Ltd. All rights reserved.
+#  Copyright (c) 2015 - 2019, Linaro Ltd. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
-#
 ##
 
 [Defines]
-  INF_VERSION                    = 0x00010005
+  INF_VERSION                    = 0x0001001B
   BASE_NAME                      = ArmSoftFloatLib
   FILE_GUID                      = a485f921-749e-41a0-9f91-62f09a38721c
   MODULE_TYPE                    = BASE
@@ -22,26 +21,71 @@
 #
 
 [Sources]
-  bits32/softfloat.c
-  Arm/__aeabi_dcmpeq.c
-  Arm/__aeabi_fcmpeq.c
-  Arm/__aeabi_dcmpge.c
-  Arm/__aeabi_fcmpge.c
-  Arm/__aeabi_dcmpgt.c
-  Arm/__aeabi_fcmpgt.c
-  Arm/__aeabi_dcmple.c
-  Arm/__aeabi_fcmple.c
-  Arm/__aeabi_dcmplt.c
-  Arm/__aeabi_fcmplt.c
-  Arm/__aeabi_dcmpun.c
-  Arm/__aeabi_fcmpun.c
+  SoftFloat-3e/build/Linux-ARM-VFPv2-GCC/platform.h
+  SoftFloat-3e/source/ARM-VFPv2/s_propagateNaNF64UI.c
+  SoftFloat-3e/source/ARM-VFPv2/softfloat_raiseFlags.c
+  SoftFloat-3e/source/ARM-VFPv2/specialize.h
+  SoftFloat-3e/source/f32_add.c
+  SoftFloat-3e/source/f32_div.c
+  SoftFloat-3e/source/f32_eq.c
+  SoftFloat-3e/source/f32_le.c
+  SoftFloat-3e/source/f32_lt.c
+  SoftFloat-3e/source/f32_mul.c
+  SoftFloat-3e/source/f32_sub.c
+  SoftFloat-3e/source/f32_to_f64.c
+  SoftFloat-3e/source/f32_to_i32_r_minMag.c
+  SoftFloat-3e/source/f32_to_i64_r_minMag.c
+  SoftFloat-3e/source/f32_to_ui32_r_minMag.c
+  SoftFloat-3e/source/f32_to_ui64_r_minMag.c
+  SoftFloat-3e/source/f64_add.c
+  SoftFloat-3e/source/f64_div.c
+  SoftFloat-3e/source/f64_eq.c
+  SoftFloat-3e/source/f64_le.c
+  SoftFloat-3e/source/f64_lt.c
+  SoftFloat-3e/source/f64_mul.c
+  SoftFloat-3e/source/f64_sub.c
+  SoftFloat-3e/source/f64_to_f32.c
+  SoftFloat-3e/source/f64_to_i32_r_minMag.c
+  SoftFloat-3e/source/f64_to_i64_r_minMag.c
+  SoftFloat-3e/source/f64_to_ui32_r_minMag.c
+  SoftFloat-3e/source/f64_to_ui64_r_minMag.c
+  SoftFloat-3e/source/i32_to_f32.c
+  SoftFloat-3e/source/i32_to_f64.c
+  SoftFloat-3e/source/i64_to_f32.c
+  SoftFloat-3e/source/i64_to_f64.c
+  SoftFloat-3e/source/include/internals.h
+  SoftFloat-3e/source/include/opts-GCC.h
+  SoftFloat-3e/source/include/primitiveTypes.h
+  SoftFloat-3e/source/include/primitives.h
+  SoftFloat-3e/source/include/softfloat.h
+  SoftFloat-3e/source/include/softfloat_types.h
+  SoftFloat-3e/source/s_addMagsF32.c
+  SoftFloat-3e/source/s_addMagsF64.c
+  SoftFloat-3e/source/s_countLeadingZeros32.c
+  SoftFloat-3e/source/s_countLeadingZeros64.c
+  SoftFloat-3e/source/s_countLeadingZeros8.c
+  SoftFloat-3e/source/s_mul64To128.c
+  SoftFloat-3e/source/s_normRoundPackToF32.c
+  SoftFloat-3e/source/s_normRoundPackToF64.c
+  SoftFloat-3e/source/s_normSubnormalF32Sig.c
+  SoftFloat-3e/source/s_normSubnormalF64Sig.c
+  SoftFloat-3e/source/s_roundPackToF32.c
+  SoftFloat-3e/source/s_roundPackToF64.c
+  SoftFloat-3e/source/s_shiftRightJam32.c
+  SoftFloat-3e/source/s_shiftRightJam64.c
+  SoftFloat-3e/source/s_shortShiftRightJam64.c
+  SoftFloat-3e/source/s_subMagsF32.c
+  SoftFloat-3e/source/s_subMagsF64.c
+  SoftFloat-3e/source/softfloat_state.c
+  SoftFloat-3e/source/ui32_to_f32.c
+  SoftFloat-3e/source/ui32_to_f64.c
+  SoftFloat-3e/source/ui64_to_f32.c
+  SoftFloat-3e/source/ui64_to_f64.c
 
-  Arm/__aeabi_cdcmp.asm   | RVCT
-  Arm/__aeabi_cfcmp.asm   | RVCT
+  ArmSoftFloatLib.c
 
 [Packages]
   MdePkg/MdePkg.dec
 
 [BuildOptions]
-  GCC:*_*_*_CC_FLAGS = -DSOFTFLOAT_FOR_GCC -Wno-enum-compare -fno-lto
-  RVCT:*_*_*_CC_FLAGS = -DSOFTFLOAT_FOR_GCC
+  GCC:*_*_*_CC_FLAGS = -fno-lto -ffreestanding -Wno-unused-label -DSOFTFLOAT_FAST_INT64
diff --git a/ArmPkg/Library/ArmSoftFloatLib/SoftFloat-3e/build/Linux-ARM-VFPv2-GCC/platform.h b/ArmPkg/Library/ArmSoftFloatLib/SoftFloat-3e/build/Linux-ARM-VFPv2-GCC/platform.h
index 420aa4e048f6..18ed054d4f4d 100644
--- a/ArmPkg/Library/ArmSoftFloatLib/SoftFloat-3e/build/Linux-ARM-VFPv2-GCC/platform.h
+++ b/ArmPkg/Library/ArmSoftFloatLib/SoftFloat-3e/build/Linux-ARM-VFPv2-GCC/platform.h
@@ -41,7 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /*----------------------------------------------------------------------------
 *----------------------------------------------------------------------------*/
 #ifdef __GNUC_STDC_INLINE__
-#define INLINE inline
+#define INLINE inline __attribute__((always_inline))
 #else
 #define INLINE extern inline
 #endif
-- 
2.20.1


  parent reply	other threads:[~2019-05-27 20:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27 20:51 [PATCH v2 0/7] update ArmSoftFloatLib to latest upstream version Ard Biesheuvel
2019-05-27 20:51 ` [PATCH v2 1/7] ArmPkg: import latest version (3e) of the Berkeley Softfloat library Ard Biesheuvel
2019-05-27 20:51 ` Ard Biesheuvel [this message]
2019-05-27 20:51 ` [PATCH v2 3/7] ArmPkg/ArmSoftFloatLib: remove source files that are no longer used Ard Biesheuvel
2019-05-27 20:51 ` [PATCH v2 4/7] ArmPkg/ArmSoftFloatLib: remove new source files that are not used Ard Biesheuvel
2019-05-27 20:51 ` [PATCH v2 5/7] ArmPkg/ArmSoftFloatLib: add SPDX identifiers Ard Biesheuvel
2019-05-28 11:27   ` Laszlo Ersek
2019-05-28 11:28     ` Ard Biesheuvel
2019-05-28 12:22       ` Leif Lindholm
2019-05-27 20:51 ` [PATCH v2 6/7] BaseTools/tools_def CLANG3x ARM AARCH64: force use of C99 standard Ard Biesheuvel
2019-05-28  0:17   ` Liming Gao
2019-05-28  6:10     ` [edk2-devel] " Ard Biesheuvel
2019-05-28  7:37       ` Wang, Jian J
2019-05-28  8:25       ` Leif Lindholm
2019-05-27 20:51 ` [PATCH v2 7/7] ArmPkg/ArmLib ARM: set .fpu to let Clang 7 assemble ArmV7Support.S Ard Biesheuvel
2019-05-30  9:24   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-05-28  6:35 ` [PATCH v2 0/7] update ArmSoftFloatLib to latest upstream version Ard Biesheuvel
2019-05-28 11:21 ` Laszlo Ersek
2019-05-28 11:29 ` Laszlo Ersek
2019-05-28 11:39 ` Laszlo Ersek
2019-05-28 13:56   ` Ard Biesheuvel
2019-05-28 16:57   ` [edk2-devel] " Michael D Kinney
2019-05-28 15:40 ` Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190527205141.12344-3-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox