[compiler-rt] r245321 - Implement __aeabi_{f,d}rsub.

Dan Albert via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 11:10:33 PDT 2015


Author: danalbert
Date: Tue Aug 18 13:10:33 2015
New Revision: 245321

URL: http://llvm.org/viewvc/llvm-project?rev=245321&view=rev
Log:
Implement __aeabi_{f,d}rsub.

Summary: Implement the missing ARM EABI functions _aeabi_frsub and __aeabi_drsub.

Reviewers: rengolin, compnerd

Subscribers: pirama, srhines, danalbert, aemerson, llvm-commits

Differential Revision: http://reviews.llvm.org/D12088

Added:
    compiler-rt/trunk/lib/builtins/arm/aeabi_drsub.c
    compiler-rt/trunk/lib/builtins/arm/aeabi_frsub.c
    compiler-rt/trunk/test/builtins/Unit/arm/
    compiler-rt/trunk/test/builtins/Unit/arm/aeabi_drsub_test.c
    compiler-rt/trunk/test/builtins/Unit/arm/aeabi_frsub_test.c
Modified:
    compiler-rt/trunk/lib/builtins/CMakeLists.txt
    compiler-rt/trunk/lib/builtins/subdf3.c
    compiler-rt/trunk/lib/builtins/subsf3.c

Modified: compiler-rt/trunk/lib/builtins/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/CMakeLists.txt?rev=245321&r1=245320&r2=245321&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/builtins/CMakeLists.txt Tue Aug 18 13:10:33 2015
@@ -191,7 +191,9 @@ set(arm_SOURCES
   arm/addsf3vfp.S
   arm/aeabi_dcmp.S
   arm/aeabi_div0.c
+  arm/aeabi_drsub.c
   arm/aeabi_fcmp.S
+  arm/aeabi_frsub.c
   arm/aeabi_idivmod.S
   arm/aeabi_ldivmod.S
   arm/aeabi_memcmp.S

Added: compiler-rt/trunk/lib/builtins/arm/aeabi_drsub.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_drsub.c?rev=245321&view=auto
==============================================================================
--- compiler-rt/trunk/lib/builtins/arm/aeabi_drsub.c (added)
+++ compiler-rt/trunk/lib/builtins/arm/aeabi_drsub.c Tue Aug 18 13:10:33 2015
@@ -0,0 +1,19 @@
+//===-- lib/arm/aeabi_drsub.c - Double-precision subtraction --------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define DOUBLE_PRECISION
+#include "../fp_lib.h"
+
+COMPILER_RT_ABI fp_t
+__aeabi_dsub(fp_t, fp_t);
+
+COMPILER_RT_ABI fp_t
+__aeabi_drsub(fp_t a, fp_t b) {
+    return __aeabi_dsub(b, a);
+}

Added: compiler-rt/trunk/lib/builtins/arm/aeabi_frsub.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/arm/aeabi_frsub.c?rev=245321&view=auto
==============================================================================
--- compiler-rt/trunk/lib/builtins/arm/aeabi_frsub.c (added)
+++ compiler-rt/trunk/lib/builtins/arm/aeabi_frsub.c Tue Aug 18 13:10:33 2015
@@ -0,0 +1,19 @@
+//===-- lib/arm/aeabi_frsub.c - Single-precision subtraction --------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#define SINGLE_PRECISION
+#include "../fp_lib.h"
+
+COMPILER_RT_ABI fp_t
+__aeabi_fsub(fp_t, fp_t);
+
+COMPILER_RT_ABI fp_t
+__aeabi_frsub(fp_t a, fp_t b) {
+    return __aeabi_fsub(b, a);
+}

Modified: compiler-rt/trunk/lib/builtins/subdf3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/subdf3.c?rev=245321&r1=245320&r2=245321&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/subdf3.c (original)
+++ compiler-rt/trunk/lib/builtins/subdf3.c Tue Aug 18 13:10:33 2015
@@ -23,4 +23,3 @@ __subdf3(fp_t a, fp_t b) {
     return __adddf3(a, fromRep(toRep(b) ^ signBit));
 }
 
-/* FIXME: rsub for ARM EABI */

Modified: compiler-rt/trunk/lib/builtins/subsf3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/subsf3.c?rev=245321&r1=245320&r2=245321&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/subsf3.c (original)
+++ compiler-rt/trunk/lib/builtins/subsf3.c Tue Aug 18 13:10:33 2015
@@ -23,4 +23,3 @@ __subsf3(fp_t a, fp_t b) {
     return __addsf3(a, fromRep(toRep(b) ^ signBit));
 }
 
-/* FIXME: rsub for ARM EABI */

Added: compiler-rt/trunk/test/builtins/Unit/arm/aeabi_drsub_test.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/builtins/Unit/arm/aeabi_drsub_test.c?rev=245321&view=auto
==============================================================================
--- compiler-rt/trunk/test/builtins/Unit/arm/aeabi_drsub_test.c (added)
+++ compiler-rt/trunk/test/builtins/Unit/arm/aeabi_drsub_test.c Tue Aug 18 13:10:33 2015
@@ -0,0 +1,47 @@
+//===-- aeabi_drsub.c - Test __aeabi_drsub --------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __aeabi_drsub for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+#if __arm__
+extern __attribute__((pcs("aapcs"))) double __aeabi_drsub(double a, double b);
+
+int test__aeabi_drsub(double a, double b, double expected)
+{
+    double actual = __aeabi_drsub(a, b);
+    if (actual != expected)
+        printf("error in __aeabi_drsub(%f, %f) = %f, expected %f\n",
+               a, b, actual, expected);
+    return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+    if (test__aeabi_drsub(1.0, 1.0, 0.0))
+        return 1;
+    if (test__aeabi_drsub(1234.567, 765.4321, -469.134900))
+        return 1;
+    if (test__aeabi_drsub(-123.0, -678.0, -555.0))
+        return 1;
+    if (test__aeabi_drsub(0.0, -0.0, 0.0))
+        return 1;
+#else
+    printf("skipped\n");
+#endif
+    return 0;
+}

Added: compiler-rt/trunk/test/builtins/Unit/arm/aeabi_frsub_test.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/builtins/Unit/arm/aeabi_frsub_test.c?rev=245321&view=auto
==============================================================================
--- compiler-rt/trunk/test/builtins/Unit/arm/aeabi_frsub_test.c (added)
+++ compiler-rt/trunk/test/builtins/Unit/arm/aeabi_frsub_test.c Tue Aug 18 13:10:33 2015
@@ -0,0 +1,47 @@
+//===-- aeabi_frsub.c - Test __aeabi_frsub --------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file tests __aeabi_frsub for the compiler_rt library.
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+#if __arm__
+extern __attribute__((pcs("aapcs"))) float __aeabi_frsub(float a, float b);
+
+int test__aeabi_frsub(float a, float b, float expected)
+{
+    float actual = __aeabi_frsub(a, b);
+    if (actual != expected)
+        printf("error in __aeabi_frsub(%f, %f) = %f, expected %f\n",
+               a, b, actual, expected);
+    return actual != expected;
+}
+#endif
+
+int main()
+{
+#if __arm__
+    if (test__aeabi_frsub(1.0, 1.0, 0.0))
+        return 1;
+    if (test__aeabi_frsub(1234.567, 765.4321, -469.134900))
+        return 1;
+    if (test__aeabi_frsub(-123.0, -678.0, -555.0))
+        return 1;
+    if (test__aeabi_frsub(0.0, -0.0, 0.0))
+        return 1;
+#else
+    printf("skipped\n");
+#endif
+    return 0;
+}




More information about the llvm-commits mailing list