From 3a44f5e6ca1c27d08b737a5cce1daade3e645c9e Mon Sep 17 00:00:00 2001 From: nickc Date: Tue, 31 Jul 2012 09:09:29 +0000 Subject: [PATCH] * config/stormy16/lib2funcs.c (__clrsbhi2): New function. Implements __clrsb for an HImode argument. * config/stormy16/clrsbhi2.c: New file: * config/stormy16/t-stormy16 (LIB2ADD): Add clrsbhi2.c. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@189997 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgcc/ChangeLog | 7 +++++++ libgcc/config/stormy16/clrsbhi2.c | 2 ++ libgcc/config/stormy16/lib2funcs.c | 16 ++++++++++++++++ libgcc/config/stormy16/t-stormy16 | 1 + 4 files changed, 26 insertions(+) create mode 100644 libgcc/config/stormy16/clrsbhi2.c diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index bcfd22b41f9..9d629e6ab8c 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,10 @@ +2012-07-31 Nick Clifton + + * config/stormy16/lib2funcs.c (__clrsbhi2): New function. + Implements __clrsb for an HImode argument. + * config/stormy16/clrsbhi2.c: New file: + * config/stormy16/t-stormy16 (LIB2ADD): Add clrsbhi2.c. + 2012-07-22 Steven Bosscher * libgcov.c (__gcov_ior_profiler): Benign comment fix. diff --git a/libgcc/config/stormy16/clrsbhi2.c b/libgcc/config/stormy16/clrsbhi2.c new file mode 100644 index 00000000000..3ce41aca061 --- /dev/null +++ b/libgcc/config/stormy16/clrsbhi2.c @@ -0,0 +1,2 @@ +#define XSTORMY16_CLRSBHI2 +#include "lib2funcs.c" diff --git a/libgcc/config/stormy16/lib2funcs.c b/libgcc/config/stormy16/lib2funcs.c index a10a9b28119..a996fd15e24 100644 --- a/libgcc/config/stormy16/lib2funcs.c +++ b/libgcc/config/stormy16/lib2funcs.c @@ -311,6 +311,22 @@ __ffshi2 (UHWtype u) } #endif +#ifdef XSTORMY16_CLRSBHI2 +/* Returns the number of leading redundant sign bits in X. + I.e. the number of bits following the most significant bit which are + identical to it. There are no special cases for 0 or other values. */ + +int +__clrsbhi2 (HWtype x) +{ + if (x < 0) + x = ~x; + if (x == 0) + return 15; + return __builtin_clz (x) - 1; +} +#endif + #ifdef XSTORMY16_UCMPSI2 /* Performs an unsigned comparison of two 32-bit values: A and B. If A is less than B, then 0 is returned. If A is greater than B, diff --git a/libgcc/config/stormy16/t-stormy16 b/libgcc/config/stormy16/t-stormy16 index d62d167d93d..48ded89d3bf 100644 --- a/libgcc/config/stormy16/t-stormy16 +++ b/libgcc/config/stormy16/t-stormy16 @@ -33,6 +33,7 @@ LIB2ADD = \ $(srcdir)/config/stormy16/clzhi2.c \ $(srcdir)/config/stormy16/ctzhi2.c \ $(srcdir)/config/stormy16/ffshi2.c \ + $(srcdir)/config/stormy16/clrsbhi2.c \ $(srcdir)/config/stormy16/cmpsi2.c \ $(srcdir)/config/stormy16/ucmpsi2.c -- 2.11.0