Patchwork [v5,06/10] softfloat: Drop [u]int8 types in favor of int_fast8_t

login
register
mail settings
Submitter Andreas Färber
Date March 7, 2011, 12:34 a.m.
Message ID <1299458053-69428-6-git-send-email-andreas.faerber@web.de>
Download mbox | patch
Permalink /patch/85608/
State New
Headers show

Comments

Andreas Färber - March 7, 2011, 12:34 a.m.
v5:
* Initial.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 fpu/softfloat-macros.h     |   26 +++++++++---------
 fpu/softfloat-specialize.h |    2 +-
 fpu/softfloat.c            |   62 ++++++++++++++++++++++----------------------
 fpu/softfloat.h            |    4 +--
 4 files changed, 46 insertions(+), 48 deletions(-)

Patch

diff --git a/fpu/softfloat-macros.h b/fpu/softfloat-macros.h
index 7b350c0..28637d4 100644
--- a/fpu/softfloat-macros.h
+++ b/fpu/softfloat-macros.h
@@ -109,7 +109,7 @@  INLINE void
      uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr )
 {
     uint64_t z0, z1;
-    int8 negCount = ( - count ) & 63;
+    int_fast8_t negCount = ( - count ) & 63;
 
     if ( count == 0 ) {
         z1 = a1;
@@ -146,7 +146,7 @@  INLINE void
      uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr )
 {
     uint64_t z0, z1;
-    int8 negCount = ( - count ) & 63;
+    int_fast8_t negCount = ( - count ) & 63;
 
     if ( count == 0 ) {
         z1 = a1;
@@ -181,7 +181,7 @@  INLINE void
      uint64_t a0, uint64_t a1, int_fast16_t count, uint64_t *z0Ptr, uint64_t *z1Ptr )
 {
     uint64_t z0, z1;
-    int8 negCount = ( - count ) & 63;
+    int_fast8_t negCount = ( - count ) & 63;
 
     if ( count == 0 ) {
         z1 = a1;
@@ -239,7 +239,7 @@  INLINE void
  )
 {
     uint64_t z0, z1, z2;
-    int8 negCount = ( - count ) & 63;
+    int_fast8_t negCount = ( - count ) & 63;
 
     if ( count == 0 ) {
         z2 = a2;
@@ -316,7 +316,7 @@  INLINE void
  )
 {
     uint64_t z0, z1, z2;
-    int8 negCount;
+    int_fast8_t negCount;
 
     z2 = a2<<count;
     z1 = a1<<count;
@@ -373,7 +373,7 @@  INLINE void
  )
 {
     uint64_t z0, z1, z2;
-    int8 carry0, carry1;
+    int_fast8_t carry0, carry1;
 
     z2 = a2 + b2;
     carry1 = ( z2 < a2 );
@@ -429,7 +429,7 @@  INLINE void
  )
 {
     uint64_t z0, z1, z2;
-    int8 borrow0, borrow1;
+    int_fast8_t borrow0, borrow1;
 
     z2 = a2 - b2;
     borrow1 = ( a2 < b2 );
@@ -590,7 +590,7 @@  static uint32_t estimateSqrt32( int_fast16_t aExp, uint32_t a )
         0x0A2D, 0x08AF, 0x075A, 0x0629, 0x051A, 0x0429, 0x0356, 0x029E,
         0x0200, 0x0179, 0x0109, 0x00AF, 0x0068, 0x0034, 0x0012, 0x0002
     };
-    int8 index;
+    int_fast8_t index;
     uint32_t z;
 
     index = ( a>>27 ) & 15;
@@ -614,9 +614,9 @@  static uint32_t estimateSqrt32( int_fast16_t aExp, uint32_t a )
 | `a'.  If `a' is zero, 32 is returned.
 *----------------------------------------------------------------------------*/
 
-static int8 countLeadingZeros32( uint32_t a )
+static int_fast8_t countLeadingZeros32( uint32_t a )
 {
-    static const int8 countLeadingZerosHigh[] = {
+    static const int_fast8_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,
@@ -634,7 +634,7 @@  static int8 countLeadingZeros32( uint32_t a )
         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 shiftCount;
+    int_fast8_t shiftCount;
 
     shiftCount = 0;
     if ( a < 0x10000 ) {
@@ -655,9 +655,9 @@  static int8 countLeadingZeros32( uint32_t a )
 | `a'.  If `a' is zero, 64 is returned.
 *----------------------------------------------------------------------------*/
 
-static int8 countLeadingZeros64( uint64_t a )
+static int_fast8_t countLeadingZeros64( uint64_t a )
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     shiftCount = 0;
     if ( a < ( (uint64_t) 1 )<<32 ) {
diff --git a/fpu/softfloat-specialize.h b/fpu/softfloat-specialize.h
index 4b65de6..e81ae96 100644
--- a/fpu/softfloat-specialize.h
+++ b/fpu/softfloat-specialize.h
@@ -42,7 +42,7 @@  these four paragraphs for those parts of this code that are retained.
 | should be simply `float_exception_flags |= flags;'.
 *----------------------------------------------------------------------------*/
 
-void float_raise( int8 flags STATUS_PARAM )
+void float_raise( int_fast8_t flags STATUS_PARAM )
 {
     STATUS(float_exception_flags) |= flags;
 }
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 4e23511..e6ecf6c 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -111,9 +111,9 @@  INLINE flag extractFloat16Sign(float16 a)
 
 static int32 roundAndPackInt32( flag zSign, uint64_t absZ STATUS_PARAM)
 {
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     flag roundNearestEven;
-    int8 roundIncrement, roundBits;
+    int_fast8_t roundIncrement, roundBits;
     int32 z;
 
     roundingMode = STATUS(float_rounding_mode);
@@ -161,7 +161,7 @@  static int32 roundAndPackInt32( flag zSign, uint64_t absZ STATUS_PARAM)
 
 static int64 roundAndPackInt64( flag zSign, uint64_t absZ0, uint64_t absZ1 STATUS_PARAM)
 {
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     flag roundNearestEven, increment;
     int64 z;
 
@@ -258,7 +258,7 @@  static float32 float32_squash_input_denormal(float32 a STATUS_PARAM)
 static void
  normalizeFloat32Subnormal( uint32_t aSig, int_fast16_t *zExpPtr, uint32_t *zSigPtr )
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     shiftCount = countLeadingZeros32( aSig ) - 8;
     *zSigPtr = aSig<<shiftCount;
@@ -309,9 +309,9 @@  INLINE float32 packFloat32( flag zSign, int_fast16_t zExp, uint32_t zSig )
 
 static float32 roundAndPackFloat32( flag zSign, int_fast16_t zExp, uint32_t zSig STATUS_PARAM)
 {
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     flag roundNearestEven;
-    int8 roundIncrement, roundBits;
+    int_fast8_t roundIncrement, roundBits;
     flag isTiny;
 
     roundingMode = STATUS(float_rounding_mode);
@@ -372,7 +372,7 @@  static float32 roundAndPackFloat32( flag zSign, int_fast16_t zExp, uint32_t zSig
 static float32
  normalizeRoundAndPackFloat32( flag zSign, int_fast16_t zExp, uint32_t zSig STATUS_PARAM)
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     shiftCount = countLeadingZeros32( zSig ) - 1;
     return roundAndPackFloat32( zSign, zExp - shiftCount, zSig<<shiftCount STATUS_VAR);
@@ -437,7 +437,7 @@  static float64 float64_squash_input_denormal(float64 a STATUS_PARAM)
 static void
  normalizeFloat64Subnormal( uint64_t aSig, int_fast16_t *zExpPtr, uint64_t *zSigPtr )
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     shiftCount = countLeadingZeros64( aSig ) - 11;
     *zSigPtr = aSig<<shiftCount;
@@ -488,7 +488,7 @@  INLINE float64 packFloat64( flag zSign, int_fast16_t zExp, uint64_t zSig )
 
 static float64 roundAndPackFloat64( flag zSign, int_fast16_t zExp, uint64_t zSig STATUS_PARAM)
 {
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     flag roundNearestEven;
     int_fast16_t roundIncrement, roundBits;
     flag isTiny;
@@ -551,7 +551,7 @@  static float64 roundAndPackFloat64( flag zSign, int_fast16_t zExp, uint64_t zSig
 static float64
  normalizeRoundAndPackFloat64( flag zSign, int_fast16_t zExp, uint64_t zSig STATUS_PARAM)
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     shiftCount = countLeadingZeros64( zSig ) - 1;
     return roundAndPackFloat64( zSign, zExp - shiftCount, zSig<<shiftCount STATUS_VAR);
@@ -606,7 +606,7 @@  INLINE flag extractFloatx80Sign( floatx80 a )
 static void
  normalizeFloatx80Subnormal( uint64_t aSig, int32 *zExpPtr, uint64_t *zSigPtr )
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     shiftCount = countLeadingZeros64( aSig );
     *zSigPtr = aSig<<shiftCount;
@@ -655,10 +655,10 @@  INLINE floatx80 packFloatx80( flag zSign, int32 zExp, uint64_t zSig )
 
 static floatx80
  roundAndPackFloatx80(
-     int8 roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1
+     int_fast8_t roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1
  STATUS_PARAM)
 {
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     flag roundNearestEven, increment, isTiny;
     int64 roundIncrement, roundMask, roundBits;
 
@@ -824,10 +824,10 @@  static floatx80
 
 static floatx80
  normalizeRoundAndPackFloatx80(
-     int8 roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1
+     int_fast8_t roundingPrecision, flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1
  STATUS_PARAM)
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     if ( zSig0 == 0 ) {
         zSig0 = zSig1;
@@ -912,7 +912,7 @@  static void
      uint64_t *zSig1Ptr
  )
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     if ( aSig0 == 0 ) {
         shiftCount = countLeadingZeros64( aSig1 ) - 15;
@@ -983,7 +983,7 @@  static float128
  roundAndPackFloat128(
      flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1, uint64_t zSig2 STATUS_PARAM)
 {
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     flag roundNearestEven, increment, isTiny;
 
     roundingMode = STATUS(float_rounding_mode);
@@ -1084,7 +1084,7 @@  static float128
  normalizeRoundAndPackFloat128(
      flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1 STATUS_PARAM)
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
     uint64_t zSig2;
 
     if ( zSig0 == 0 ) {
@@ -1135,7 +1135,7 @@  float64 int32_to_float64( int32 a STATUS_PARAM )
 {
     flag zSign;
     uint32 absA;
-    int8 shiftCount;
+    int_fast8_t shiftCount;
     uint64_t zSig;
 
     if ( a == 0 ) return float64_zero;
@@ -1160,7 +1160,7 @@  floatx80 int32_to_floatx80( int32 a STATUS_PARAM )
 {
     flag zSign;
     uint32 absA;
-    int8 shiftCount;
+    int_fast8_t shiftCount;
     uint64_t zSig;
 
     if ( a == 0 ) return packFloatx80( 0, 0, 0 );
@@ -1186,7 +1186,7 @@  float128 int32_to_float128( int32 a STATUS_PARAM )
 {
     flag zSign;
     uint32 absA;
-    int8 shiftCount;
+    int_fast8_t shiftCount;
     uint64_t zSig0;
 
     if ( a == 0 ) return packFloat128( 0, 0, 0, 0 );
@@ -1210,7 +1210,7 @@  float32 int64_to_float32( int64 a STATUS_PARAM )
 {
     flag zSign;
     uint64 absA;
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     if ( a == 0 ) return float32_zero;
     zSign = ( a < 0 );
@@ -1234,7 +1234,7 @@  float32 int64_to_float32( int64 a STATUS_PARAM )
 
 float32 uint64_to_float32( uint64 a STATUS_PARAM )
 {
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     if ( a == 0 ) return float32_zero;
     shiftCount = countLeadingZeros64( a ) - 40;
@@ -1292,7 +1292,7 @@  floatx80 int64_to_floatx80( int64 a STATUS_PARAM )
 {
     flag zSign;
     uint64 absA;
-    int8 shiftCount;
+    int_fast8_t shiftCount;
 
     if ( a == 0 ) return packFloatx80( 0, 0, 0 );
     zSign = ( a < 0 );
@@ -1316,7 +1316,7 @@  float128 int64_to_float128( int64 a STATUS_PARAM )
 {
     flag zSign;
     uint64 absA;
-    int8 shiftCount;
+    int_fast8_t shiftCount;
     int32 zExp;
     uint64_t zSig0, zSig1;
 
@@ -1658,7 +1658,7 @@  float32 float32_round_to_int( float32 a STATUS_PARAM)
     flag aSign;
     int_fast16_t aExp;
     uint32_t lastBitMask, roundBitsMask;
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     uint32_t z;
     a = float32_squash_input_denormal(a STATUS_VAR);
 
@@ -2771,7 +2771,7 @@  float32 float16_to_float32(float16 a, flag ieee STATUS_PARAM)
         return packFloat32(aSign, 0xff, aSig << 13);
     }
     if (aExp == 0) {
-        int8 shiftCount;
+        int_fast8_t shiftCount;
 
         if (aSig == 0) {
             return packFloat32(aSign, 0, 0);
@@ -2791,7 +2791,7 @@  float16 float32_to_float16(float32 a, flag ieee STATUS_PARAM)
     uint32_t aSig;
     uint32_t mask;
     uint32_t increment;
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     a = float32_squash_input_denormal(a STATUS_VAR);
 
     aSig = extractFloat32Frac( a );
@@ -2960,7 +2960,7 @@  float64 float64_round_to_int( float64 a STATUS_PARAM )
     flag aSign;
     int_fast16_t aExp;
     uint64_t lastBitMask, roundBitsMask;
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     uint64_t z;
     a = float64_squash_input_denormal(a STATUS_VAR);
 
@@ -3958,7 +3958,7 @@  floatx80 floatx80_round_to_int( floatx80 a STATUS_PARAM )
     flag aSign;
     int32 aExp;
     uint64_t lastBitMask, roundBitsMask;
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     floatx80 z;
 
     aExp = extractFloatx80Exp( a );
@@ -4999,7 +4999,7 @@  float128 float128_round_to_int( float128 a STATUS_PARAM )
     flag aSign;
     int32 aExp;
     uint64_t lastBitMask, roundBitsMask;
-    int8 roundingMode;
+    int_fast8_t roundingMode;
     float128 z;
 
     aExp = extractFloat128Exp( a );
diff --git a/fpu/softfloat.h b/fpu/softfloat.h
index 795c2ea..c599cc2 100644
--- a/fpu/softfloat.h
+++ b/fpu/softfloat.h
@@ -54,8 +54,6 @@  these four paragraphs for those parts of this code that are retained.
 | to the same as `int'.
 *----------------------------------------------------------------------------*/
 typedef uint8_t flag;
-typedef uint8_t uint8;
-typedef int8_t int8;
 typedef unsigned int uint32;
 typedef signed int int32;
 typedef uint64_t uint64;
@@ -231,7 +229,7 @@  void set_floatx80_rounding_precision(int val STATUS_PARAM);
 | Routine to raise any or all of the software IEC/IEEE floating-point
 | exception flags.
 *----------------------------------------------------------------------------*/
-void float_raise( int8 flags STATUS_PARAM);
+void float_raise( int_fast8_t flags STATUS_PARAM);
 
 /*----------------------------------------------------------------------------
 | Software IEC/IEEE integer-to-floating-point conversion routines.