From: nickc Date: Wed, 1 Aug 2012 09:36:01 +0000 (+0000) Subject: * config/m32c/lib2funcs.c (__clrsbhi2): New function. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a575acb283ccbe98f47a7f5b58b15bdcb6df313f;p=thirdparty%2Fgcc.git * config/m32c/lib2funcs.c (__clrsbhi2): New function. Implements __clrsb for an HImode argument. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@190032 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index 9d629e6ab8c2..62f9446ea491 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2012-08-01 Nick Clifton + + * config/m32c/lib2funcs.c (__clrsbhi2): New function. + Implements __clrsb for an HImode argument. + 2012-07-31 Nick Clifton * config/stormy16/lib2funcs.c (__clrsbhi2): New function. diff --git a/libgcc/config/m32c/lib2funcs.c b/libgcc/config/m32c/lib2funcs.c index 274affc4ab09..76b237cdf269 100644 --- a/libgcc/config/m32c/lib2funcs.c +++ b/libgcc/config/m32c/lib2funcs.c @@ -1,5 +1,5 @@ /* libgcc routines for R8C/M16C/M32C - Copyright (C) 2005, 2009 + Copyright (C) 2005, 2009, 2012 Free Software Foundation, Inc. Contributed by Red Hat. @@ -132,3 +132,17 @@ __umoddi3 (uint32_type a, uint32_type b) { return udivmodsi4 (a, b, 1); } + +/* 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 (word_type x) +{ + if (x < 0) + x = ~x; + if (x == 0) + return 15; + return __builtin_clz (x) - 1; +}