projects
/
gcc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
aix: FAT libraries: test native compiler mode directly
[gcc.git]
/
libgcc
/
fixed-bit.c
diff --git
a/libgcc/fixed-bit.c
b/libgcc/fixed-bit.c
index d434d131eecf151b562d22f18fe220a98c6cd3d8..efb5e180d2307afee53725ced1f2e57d5f365f96 100644
(file)
--- a/
libgcc/fixed-bit.c
+++ b/
libgcc/fixed-bit.c
@@
-1,5
+1,5
@@
/* This is a software fixed-point library.
/* This is a software fixed-point library.
- Copyright (C) 2007
, 2009
Free Software Foundation, Inc.
+ Copyright (C) 2007
-2020
Free Software Foundation, Inc.
This file is part of GCC.
This file is part of GCC.
@@
-46,6
+46,7
@@
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "tsystem.h"
#include "coretypes.h"
#include "tm.h"
#include "tsystem.h"
#include "coretypes.h"
#include "tm.h"
+#include "libgcc_tm.h"
#ifndef MIN_UNITS_PER_WORD
#define MIN_UNITS_PER_WORD UNITS_PER_WORD
#ifndef MIN_UNITS_PER_WORD
#define MIN_UNITS_PER_WORD UNITS_PER_WORD
@@
-79,15
+80,14
@@
FIXED_SSADD (FIXED_C_TYPE a, FIXED_C_TYPE b)
INT_C_TYPE x, y, z;
memcpy (&x, &a, FIXED_SIZE);
memcpy (&y, &b, FIXED_SIZE);
INT_C_TYPE x, y, z;
memcpy (&x, &a, FIXED_SIZE);
memcpy (&y, &b, FIXED_SIZE);
- z = x + y;
+ z = x +
(UINT_C_TYPE)
y;
if ((((x ^ y) >> I_F_BITS) & 1) == 0)
{
if (((z ^ x) >> I_F_BITS) & 1)
{
if ((((x ^ y) >> I_F_BITS) & 1) == 0)
{
if (((z ^ x) >> I_F_BITS) & 1)
{
- z = 1;
- z = z << I_F_BITS;
- if (x >= 0)
- z--;
+ z = ((UINT_C_TYPE) 1) << I_F_BITS;
+ if (x >= 0)
+ z -= (UINT_C_TYPE) 1;
}
}
#if HAVE_PADDING_BITS
}
}
#if HAVE_PADDING_BITS
@@
-151,15
+151,14
@@
FIXED_SSSUB (FIXED_C_TYPE a, FIXED_C_TYPE b)
INT_C_TYPE x, y, z;
memcpy (&x, &a, FIXED_SIZE);
memcpy (&y, &b, FIXED_SIZE);
INT_C_TYPE x, y, z;
memcpy (&x, &a, FIXED_SIZE);
memcpy (&y, &b, FIXED_SIZE);
- z = x - y;
+ z = x -
(UINT_C_TYPE)
y;
if (((x ^ y) >> I_F_BITS) & 1)
{
if (((z ^ x) >> I_F_BITS) & 1)
{
if (((x ^ y) >> I_F_BITS) & 1)
{
if (((z ^ x) >> I_F_BITS) & 1)
{
- z = 1;
- z = z << I_F_BITS;
- if (x >= 0)
- z--;
+ z = ((UINT_C_TYPE) 1) << I_F_BITS;
+ if (x >= 0)
+ z -= (UINT_C_TYPE) 1;
}
}
#if HAVE_PADDING_BITS
}
}
#if HAVE_PADDING_BITS
@@
-568,16
+567,11
@@
FIXED_SSNEG (FIXED_C_TYPE a)
INT_C_TYPE x, y, z;
memcpy (&y, &a, FIXED_SIZE);
x = 0;
INT_C_TYPE x, y, z;
memcpy (&y, &a, FIXED_SIZE);
x = 0;
- z = x - y;
+ z = x -
(UINT_C_TYPE)
y;
if (((x ^ y) >> I_F_BITS) & 1)
{
if (((z ^ x) >> I_F_BITS) & 1)
if (((x ^ y) >> I_F_BITS) & 1)
{
if (((z ^ x) >> I_F_BITS) & 1)
- {
- z = 1;
- z = z << I_F_BITS;
- if (x >= 0)
- z--;
- }
+ z = (((UINT_C_TYPE) 1) << I_F_BITS) - 1;
}
#if HAVE_PADDING_BITS
z = z << PADDING_BITS;
}
#if HAVE_PADDING_BITS
z = z << PADDING_BITS;
@@
-767,11
+761,12
@@
SATFRACT (FROM_FIXED_C_TYPE a)
#if FROM_MODE_UNSIGNED == 0
BIG_SINT_C_TYPE high, low;
BIG_SINT_C_TYPE max_high, max_low;
#if FROM_MODE_UNSIGNED == 0
BIG_SINT_C_TYPE high, low;
BIG_SINT_C_TYPE max_high, max_low;
+#if TO_MODE_UNSIGNED == 0
BIG_SINT_C_TYPE min_high, min_low;
BIG_SINT_C_TYPE min_high, min_low;
+#endif
#else
BIG_UINT_C_TYPE high, low;
BIG_UINT_C_TYPE max_high, max_low;
#else
BIG_UINT_C_TYPE high, low;
BIG_UINT_C_TYPE max_high, max_low;
- BIG_UINT_C_TYPE min_high, min_low;
#endif
#if TO_FBITS > FROM_FBITS
BIG_UINT_C_TYPE utemp;
#endif
#if TO_FBITS > FROM_FBITS
BIG_UINT_C_TYPE utemp;
@@
-818,13
+813,12
@@
SATFRACT (FROM_FIXED_C_TYPE a)
#endif
#if TO_MODE_UNSIGNED == 0
#endif
#if TO_MODE_UNSIGNED == 0
- min_high = -1;
stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
+#if FROM_MODE_UNSIGNED == 0
+ min_high = -1;
min_low = stemp;
min_low = stemp;
-#else
- min_high = 0;
- min_low = 0;
+#endif
#endif
#if FROM_MODE_UNSIGNED == 0 && TO_MODE_UNSIGNED == 0
#endif
#if FROM_MODE_UNSIGNED == 0 && TO_MODE_UNSIGNED == 0
@@
-963,7
+957,7
@@
FRACT (FROM_INT_C_TYPE a)
#endif /* defined(FRACT) && FROM_TYPE == 1 && TO_TYPE == 4 */
/* Signed int -> Fixed with saturation. */
#endif /* defined(FRACT) && FROM_TYPE == 1 && TO_TYPE == 4 */
/* Signed int -> Fixed with saturation. */
-#if defined(SATFRACT) && defined(L_satfract) &&FROM_TYPE == 1 && TO_TYPE == 4
+#if defined(SATFRACT) && defined(L_satfract) &&
FROM_TYPE == 1 && TO_TYPE == 4
TO_FIXED_C_TYPE
SATFRACT (FROM_INT_C_TYPE a)
{
TO_FIXED_C_TYPE
SATFRACT (FROM_INT_C_TYPE a)
{
@@
-972,8
+966,8
@@
SATFRACT (FROM_INT_C_TYPE a)
FROM_INT_C_TYPE x = a;
BIG_SINT_C_TYPE high, low;
BIG_SINT_C_TYPE max_high, max_low;
FROM_INT_C_TYPE x = a;
BIG_SINT_C_TYPE high, low;
BIG_SINT_C_TYPE max_high, max_low;
- BIG_SINT_C_TYPE min_high, min_low;
#if TO_MODE_UNSIGNED == 0
#if TO_MODE_UNSIGNED == 0
+ BIG_SINT_C_TYPE min_high, min_low;
BIG_SINT_C_TYPE stemp;
#endif
#if BIG_WIDTH != TO_FBITS
BIG_SINT_C_TYPE stemp;
#endif
#if BIG_WIDTH != TO_FBITS
@@
-1014,12
+1008,7
@@
SATFRACT (FROM_INT_C_TYPE a)
stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
min_low = stemp;
stemp = (BIG_SINT_C_TYPE)1 << (BIG_WIDTH - 1);
stemp = stemp >> (BIG_WIDTH - 1 - TO_I_F_BITS);
min_low = stemp;
-#else
- min_high = 0;
- min_low = 0;
-#endif
-#if TO_MODE_UNSIGNED == 0
/* Signed -> Signed. */
if ((BIG_SINT_C_TYPE) high > (BIG_SINT_C_TYPE) max_high
|| ((BIG_SINT_C_TYPE) high == (BIG_SINT_C_TYPE) max_high
/* Signed -> Signed. */
if ((BIG_SINT_C_TYPE) high > (BIG_SINT_C_TYPE) max_high
|| ((BIG_SINT_C_TYPE) high == (BIG_SINT_C_TYPE) max_high