Use clang's builtins for sqrt()/sqrtf() and lrint() family.

Bug: https://github.com/google/android-riscv64/issues/12
Test: llvm-objdump
Change-Id: I2b5647ca245b28433faabe633d970ea2fd69c763
diff --git a/libm/Android.bp b/libm/Android.bp
index 3e271fa..b6c7b6a 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -305,8 +305,6 @@
         arm64: {
             srcs: [
                 "arm64/fenv.c",
-                "arm64/lrint.S",
-                "arm64/sqrt.S",
             ],
             exclude_srcs: [
                 "upstream-freebsd/lib/msun/src/s_ceil.c",
@@ -342,8 +340,6 @@
         riscv64: {
             srcs: [
                 "riscv64/fenv.c",
-                "riscv64/lrint.S",
-                "riscv64/sqrt.S",
             ],
 
             exclude_srcs: [
diff --git a/libm/arm64/lrint.S b/libm/arm64/lrint.S
deleted file mode 100644
index e835d08..0000000
--- a/libm/arm64/lrint.S
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <private/bionic_asm.h>
-
-ENTRY(lrint)
-  frintX d0, d0
-  fcvtzs x0, d0
-  ret
-END(lrint)
-
-ENTRY(lrintf)
-  frintX s0, s0
-  fcvtzs x0, s0
-  ret
-END(lrintf)
-
-// sizeof(long) and sizeof(long long) are the same for aarch64
-ALIAS_SYMBOL(llrint, lrint);
-
-ALIAS_SYMBOL(llrintf, lrintf);
-
-NOTE_GNU_PROPERTY()
diff --git a/libm/arm64/sqrt.S b/libm/arm64/sqrt.S
deleted file mode 100644
index 0659b13..0000000
--- a/libm/arm64/sqrt.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <private/bionic_asm.h>
-
-ENTRY(sqrt)
-  fsqrt d0, d0
-  ret
-END(sqrt)
-
-ENTRY(sqrtf)
-  fsqrt s0, s0
-  ret
-END(sqrtf)
-
-NOTE_GNU_PROPERTY()
diff --git a/libm/builtins.cpp b/libm/builtins.cpp
index 58cd81d..256436e 100644
--- a/libm/builtins.cpp
+++ b/libm/builtins.cpp
@@ -47,6 +47,11 @@
 float fminf(float x, float y) { return __builtin_fminf(x, y); }
 double fmin(double x, double y) { return __builtin_fmin(x, y); }
 
+long lrint(double x) { return __builtin_lrint(x); }
+long lrintf(float x) { return __builtin_lrintf(x); }
+long long llrint(double x) { return __builtin_llrint(x); }
+long long llrintf(float x) { return __builtin_llrintf(x); }
+
 long lround(double x) { return __builtin_lround(x); }
 long lroundf(float x) { return __builtin_lroundf(x); }
 long long llround(double x) { return __builtin_llround(x); }
@@ -59,7 +64,14 @@
 
 float roundf(float x) { return __builtin_roundf(x); }
 double round(double x) { return __builtin_round(x); }
+#endif
 
+#if defined(__aarch64__) || defined(__riscv)
+float sqrtf(float x) { return __builtin_sqrtf(x); }
+double sqrt(double x) { return __builtin_sqrt(x); }
+#endif
+
+#if defined(__aarch64__)
 float truncf(float x) { return __builtin_truncf(x); }
 double trunc(double x) { return __builtin_trunc(x); }
 #endif
diff --git a/libm/riscv64/lrint.S b/libm/riscv64/lrint.S
deleted file mode 100644
index eb13833..0000000
--- a/libm/riscv64/lrint.S
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- * All rights reserved.
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE 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 <private/bionic_asm.h>
-
-ENTRY(lrint)
-  fcvt.l.d a0, fa0, dyn
-  ret
-END(lrint)
-
-ENTRY(lrintf)
-  fcvt.l.s a0, fa0, dyn
-  ret
-END(lrintf)
-
-// sizeof(long) and sizeof(long long) are the same for riscv64
-ALIAS_SYMBOL(llrint, lrint);
-
-ALIAS_SYMBOL(llrintf, lrintf);
diff --git a/libm/riscv64/sqrt.S b/libm/riscv64/sqrt.S
deleted file mode 100644
index 0db1335..0000000
--- a/libm/riscv64/sqrt.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- * All rights reserved.
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE 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 <private/bionic_asm.h>
-
-ENTRY(sqrt)
-  fsqrt.d fa0, fa0
-  ret
-END(sqrt)
-
-ENTRY(sqrtf)
-  fsqrt.s fa0, fa0
-  ret
-END(sqrtf)