svn commit: r316511 - in head: contrib/compiler-rt/lib/builtins lib/libcompiler_rt
John Baldwin
jhb at FreeBSD.org
Wed Apr 5 02:40:54 UTC 2017
Author: jhb
Date: Wed Apr 5 02:40:53 2017
New Revision: 316511
URL: https://svnweb.freebsd.org/changeset/base/316511
Log:
Add an implementation of __ffssi2() derived from __ffsdi2().
Newer versions of GCC include an __ffssi2() symbol in libgcc and the
compiler can emit calls to it in generated code. This is true for at
least GCC 6.2 when compiling world for mips and mips64.
Reviewed by: jmallett, dim
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10086
Added:
head/contrib/compiler-rt/lib/builtins/ffssi2.c (contents, props changed)
Modified:
head/contrib/compiler-rt/lib/builtins/README.txt
head/lib/libcompiler_rt/Makefile.inc
Modified: head/contrib/compiler-rt/lib/builtins/README.txt
==============================================================================
--- head/contrib/compiler-rt/lib/builtins/README.txt Wed Apr 5 01:46:41 2017 (r316510)
+++ head/contrib/compiler-rt/lib/builtins/README.txt Wed Apr 5 02:40:53 2017 (r316511)
@@ -45,6 +45,7 @@ si_int __ctzsi2(si_int a); // count tra
si_int __ctzdi2(di_int a); // count trailing zeros
si_int __ctzti2(ti_int a); // count trailing zeros
+si_int __ffssi2(si_int a); // find least significant 1 bit
si_int __ffsdi2(di_int a); // find least significant 1 bit
si_int __ffsti2(ti_int a); // find least significant 1 bit
Added: head/contrib/compiler-rt/lib/builtins/ffssi2.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/contrib/compiler-rt/lib/builtins/ffssi2.c Wed Apr 5 02:40:53 2017 (r316511)
@@ -0,0 +1,29 @@
+/* ===-- ffssi2.c - Implement __ffssi2 -------------------------------------===
+ *
+ * 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 implements __ffssi2 for the compiler_rt library.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+#include "int_lib.h"
+
+/* Returns: the index of the least significant 1-bit in a, or
+ * the value zero if a is zero. The least significant bit is index one.
+ */
+
+COMPILER_RT_ABI si_int
+__ffssi2(si_int a)
+{
+ if (a == 0)
+ {
+ return 0;
+ }
+ return __builtin_ctz(a) + 1;
+}
Modified: head/lib/libcompiler_rt/Makefile.inc
==============================================================================
--- head/lib/libcompiler_rt/Makefile.inc Wed Apr 5 01:46:41 2017 (r316510)
+++ head/lib/libcompiler_rt/Makefile.inc Wed Apr 5 02:40:53 2017 (r316511)
@@ -38,6 +38,7 @@ SRCF+= divxc3
SRCF+= enable_execute_stack
SRCF+= eprintf
SRCF+= extendhfsf2
+SRCF+= ffssi2
SRCF+= ffsdi2
SRCF+= ffsti2
SRCF+= fixdfdi
More information about the svn-src-all
mailing list