libm: remove hand-written assembler for arm32 too.

The clang builtins for arm32 give us identical code to what we had for
sqrt()/sqrtf(), and significantly better (neon) code for
floor()/floorf() than the integer-only implementations we had.

Test: llvm-objdump
Change-Id: I224bcfcf4739a80e1a7cdd07b0b1fa232fdf2dab
diff --git a/libm/Android.bp b/libm/Android.bp
index b6c7b6a..f06bd4f 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -285,11 +285,10 @@
         arm: {
             srcs: [
                 "arm/fenv.c",
-                "arm/floor.S",
-                "arm/sqrt.S",
             ],
             exclude_srcs: [
                 "upstream-freebsd/lib/msun/src/s_floor.c",
+                "upstream-freebsd/lib/msun/src/s_floorf.c",
             ],
             instruction_set: "arm",
             pack_relocations: false,
diff --git a/libm/NOTICE b/libm/NOTICE
index bce49ad..61dd125 100644
--- a/libm/NOTICE
+++ b/libm/NOTICE
@@ -1148,37 +1148,6 @@
 
 -------------------------------------------------------------------
 
-Copyright (c) 2013-2014, NVIDIA Corporation.  All rights reserved.
-Johnny Qiu <joqiu@nvidia.com>
-Shu Zhang <chazhang@nvidia.com>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above
-      copyright notice, this list of conditions and the following
-      disclaimer in the documentation and/or other materials provided
-      with the distribution.
-    * Neither the name of The Linux Foundation nor the names of its
-      contributors may be used to endorse or promote products derived
-      from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------
-
 Copyright (c) 2014, Intel Corporation
 All rights reserved.
 
diff --git a/libm/arm/floor.S b/libm/arm/floor.S
deleted file mode 100644
index 3af8f76..0000000
--- a/libm/arm/floor.S
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2013-2014, NVIDIA Corporation.  All rights reserved.
- * Johnny Qiu <joqiu@nvidia.com>
- * Shu Zhang <chazhang@nvidia.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <float.h>
-#include <private/bionic_asm.h>
-
-ENTRY(floor)    /* x in r0, r1 */
-
-        and             r3, r1, #0x80000000     /* sign(x) */
-        bic             r1, r1, #0x80000000     /* x = abs(x) */
-
-        /* extract exp of x */
-        lsr             r2, r1, #20
-        sub             r2, r2, #0x3fc
-        subs            r2, r2, #0x3            /* r2 <- exp */
-
-        /* |x| < 1.0? */
-        blt             .Lx_lt_one
-
-        /* x < 0? */
-        cmp             r3, #0
-        bne             .Lclr_frac_neg
-
-        /* |x| <= 2^20? */
-        cmp             r2, #20
-        ble             .Lclr_frac_r1
-
-        /* |x| < 2^52? */
-        cmp             r2, #52
-        blt             .Lclr_frac_r0
-
-        /* return x */
-        bx              lr
-
-.Lclr_frac_r1:
-        rsb             r2, r2, #20
-        lsr             r1, r1, r2
-        lsl             r1, r1, r2
-        mov             r0, #0
-        bx              lr
-
-.Lclr_frac_r0:
-        rsb             r2, r2, #52
-        lsr             r0, r0, r2
-        lsl             r0, r0, r2
-        bx              lr
-
-.Lclr_frac_neg:
-        /* |x| <= 2^20? */
-        cmp             r2, #20
-        ble             .Lclr_frac_r1_neg
-
-        /* |x| < 2^52? */
-        cmp             r2, #52
-        blt             .Lclr_frac_r0_neg
-
-        /* return x */
-        orr             r1, r1, #0x80000000
-        bx              lr
-
-.Lclr_frac_r1_neg:
-        rsb             r2, r2, #20
-        mov             r3, #1
-        lsl             r3, r3, r2
-        sub             r3, r3, #1
-        and             r3, r1, r3
-        orr             r3, r3, r0
-        lsr             r1, r1, r2
-        lsl             r1, r1, r2
-        mov             r0, #0
-        b               .Lreturn_x_neg
-
-.Lclr_frac_r0_neg:
-        rsb             r2, r2, #52
-        mov             r3, #1
-        lsl             r3, r3, r2
-        sub             r3, r3, #1
-        and             r3, r0, r3
-        lsr             r0, r0, r2
-        lsl             r0, r0, r2
-        b               .Lreturn_x_neg
-
-.Lx_lt_one:
-        /* x == +-0? */
-        cmp             r0, #0
-        cmpeq           r1, #0
-        orreq           r1, r1, r3
-        bxeq            lr
-
-        /* (x > 0) ? 0 : -1 */
-        mov             r1, #0x00100000
-        mov             r0, #0
-        cmp             r3, #0
-        movne           r1, #0xc0000000
-        sub             r1, r1, #0x00100000
-        bx              lr
-
-.Lreturn_x_neg:
-        cmp             r3, #0
-        orr             r1, r1, #0x80000000
-        bxeq            lr
-
-        vmov            d16, r0, r1
-        vmov.f64        d18, #1.0
-        vsub.f64        d16, d16, d18
-        vmov            r0, r1, d16
-        bx              lr
-
-END(floor)
-
-ALIAS_SYMBOL(floorl, floor);
diff --git a/libm/arm/sqrt.S b/libm/arm/sqrt.S
deleted file mode 100644
index f2981f4..0000000
--- a/libm/arm/sqrt.S
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2013-2014, NVIDIA Corporation.  All rights reserved.
- * Johnny Qiu <joqiu@nvidia.com>
- * Shu Zhang <chazhang@nvidia.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <float.h>
-#include <private/bionic_asm.h>
-
-ENTRY(sqrt)
-    vmov.f64    d0, r0, r1
-    vsqrt.f64   d0, d0
-    vmov.f64    r0, r1, d0
-    bx          lr
-END(sqrt)
-
-ENTRY(sqrtf)
-    vmov.f32    s0, r0
-    vsqrt.f32   s0, s0
-    vmov.f32    r0, s0
-    bx          lr
-END(sqrtf)
-
-ALIAS_SYMBOL(sqrtl, sqrt);
diff --git a/libm/builtins.cpp b/libm/builtins.cpp
index 256436e..99758ff 100644
--- a/libm/builtins.cpp
+++ b/libm/builtins.cpp
@@ -32,9 +32,12 @@
 float copysignf(float x, float y) { return __builtin_copysignf(x, y); }
 #endif
 
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
 float floorf(float x) { return __builtin_floorf(x); }
 double floor(double x) { return __builtin_floor(x); }
+#if defined(__ILP32__)
+__weak_reference(floor, floorl);
+#endif
 #endif
 
 #if defined(__aarch64__) || defined(__riscv)
@@ -66,9 +69,12 @@
 double round(double x) { return __builtin_round(x); }
 #endif
 
-#if defined(__aarch64__) || defined(__riscv)
+#if defined(__arm__) || defined(__aarch64__) || defined(__riscv)
 float sqrtf(float x) { return __builtin_sqrtf(x); }
 double sqrt(double x) { return __builtin_sqrt(x); }
+#if defined(__ILP32__)
+__weak_reference(sqrt, sqrtl);
+#endif
 #endif
 
 #if defined(__aarch64__)