diff mbox series

include/fpu/softfloat-macros: Get rid of old SOFTFLOAT_GNUC_PREREQ code

Message ID 1538032576-13339-1-git-send-email-thuth@redhat.com
State New
Headers show
Series include/fpu/softfloat-macros: Get rid of old SOFTFLOAT_GNUC_PREREQ code | expand

Commit Message

Thomas Huth Sept. 27, 2018, 7:16 a.m. UTC
Our minimum required compiler for compiling QEMU is GCC 4.1 these days,
so we can drop the support for compilers which do not provide the
__builtin_clz*() functions yet.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/fpu/softfloat-macros.h | 59 ------------------------------------------
 1 file changed, 59 deletions(-)

Comments

Peter Maydell Sept. 27, 2018, 7:28 a.m. UTC | #1
On 27 September 2018 at 08:16, Thomas Huth <thuth@redhat.com> wrote:
> Our minimum required compiler for compiling QEMU is GCC 4.1 these days,
> so we can drop the support for compilers which do not provide the
> __builtin_clz*() functions yet.
>  static inline int8_t countLeadingZeros32(uint32_t a)
>  {
> -#if SOFTFLOAT_GNUC_PREREQ(3, 4)
>      if (a) {
>          return __builtin_clz(a);
>      } else {
>          return 32;
>      }

This can just be written
       return clz32(a);

>  static inline int8_t countLeadingZeros64(uint64_t a)
>  {
> -#if SOFTFLOAT_GNUC_PREREQ(3, 4)
>      if (a) {
>          return __builtin_clzll(a);
>      } else {
>          return 64;
>      }

and this as
       return clz64(a);

using QEMU's versions of these functions from host-utils.h.

Now we've decided we really "own" our copy of softfloat, we
might as well just replace all the countLeadingZeros32() and
countLeadingZeros64() calls with clz32() and clz64(), for
consistency with the rest of the codebase.

thanks
-- PMM
diff mbox series

Patch

diff --git a/include/fpu/softfloat-macros.h b/include/fpu/softfloat-macros.h
index 35e1603..f65c90d 100644
--- a/include/fpu/softfloat-macros.h
+++ b/include/fpu/softfloat-macros.h
@@ -80,17 +80,6 @@  this code that are retained.
  */
 
 /*----------------------------------------------------------------------------
-| This macro tests for minimum version of the GNU C compiler.
-*----------------------------------------------------------------------------*/
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
-# define SOFTFLOAT_GNUC_PREREQ(maj, min) \
-         ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-#else
-# define SOFTFLOAT_GNUC_PREREQ(maj, min) 0
-#endif
-
-
-/*----------------------------------------------------------------------------
 | Shifts `a' right by the number of bits given in `count'.  If any nonzero
 | bits are shifted off, they are ``jammed'' into the least significant bit of
 | the result by setting the least significant bit to 1.  The value of `count'
@@ -719,45 +708,11 @@  static inline uint32_t estimateSqrt32(int aExp, uint32_t a)
 
 static inline int8_t countLeadingZeros32(uint32_t a)
 {
-#if SOFTFLOAT_GNUC_PREREQ(3, 4)
     if (a) {
         return __builtin_clz(a);
     } else {
         return 32;
     }
-#else
-    static const int8_t countLeadingZerosHigh[] = {
-        8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
-        3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-    };
-    int8_t shiftCount;
-
-    shiftCount = 0;
-    if ( a < 0x10000 ) {
-        shiftCount += 16;
-        a <<= 16;
-    }
-    if ( a < 0x1000000 ) {
-        shiftCount += 8;
-        a <<= 8;
-    }
-    shiftCount += countLeadingZerosHigh[ a>>24 ];
-    return shiftCount;
-#endif
 }
 
 /*----------------------------------------------------------------------------
@@ -767,25 +722,11 @@  static inline int8_t countLeadingZeros32(uint32_t a)
 
 static inline int8_t countLeadingZeros64(uint64_t a)
 {
-#if SOFTFLOAT_GNUC_PREREQ(3, 4)
     if (a) {
         return __builtin_clzll(a);
     } else {
         return 64;
     }
-#else
-    int8_t shiftCount;
-
-    shiftCount = 0;
-    if ( a < ( (uint64_t) 1 )<<32 ) {
-        shiftCount += 32;
-    }
-    else {
-        a >>= 32;
-    }
-    shiftCount += countLeadingZeros32( a );
-    return shiftCount;
-#endif
 }
 
 /*----------------------------------------------------------------------------