summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-11-27 18:56:10 +0000
committerNick Clifton <nickc@gcc.gnu.org>2009-11-27 18:56:10 +0000
commitba96438334721b0d48bf9a1413a6c0963ddbd30f (patch)
treec9d56ccf47b4f1ac9b76b795492e4508065b5dae
parentc7f06e130978925eec2f188d7d2f3ec9b378e8ac (diff)
downloadgcc-ba96438334721b0d48bf9a1413a6c0963ddbd30f.tar.gz
stormy16-lib2.c: Arrange for separate compilation of each function.
* config/stormy16/stormy16-lib2.c: Arrange for separate compilation of each function. (__ffshi2): New function. (__stormy16_count_leading_zeros): New function. * config/stormy16/t-stormy16 (LIB2FUNCS_EXTRA): Use stub files to compile each function into its own object file. (stormy16-lib2-ashlsi3.c): New stub file. (stormy16-lib2-ashrsi3.c): New stub file. (stormy16-lib2-clzhi2.c): New stub file. (stormy16-lib2-count-leading-zeros.c): New stub file. (stormy16-lib2-ctzhi2.c): New stub file. (stormy16-lib2-divsi3.c): New stub file. (stormy16-lib2-ffshi2.c): New stub file. (stormy16-lib2-lshrsi3.c): New stub file. (stormy16-lib2-modsi3.c): New stub file. (stormy16-lib2-parityhi2.c): New stub file. (stormy16-lib2-popcounthi2.c): New stub file. (stormy16-lib2-udivmodsi4.c): New stub file. (stormy16-lib2-udivsi3.c): New stub file. (stormy16-lib2-umodsi3.c): New stub file. * longlong.h (count_leading_zeros): Define macro for stormy16 target. (COUNT_LEADING_ZEROS_0): Likewise. From-SVN: r154713
-rw-r--r--gcc/ChangeLog26
-rw-r--r--gcc/config/stormy16/stormy16-lib2-ashlsi3.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-ashrsi3.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-clzhi2.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-count-leading-zeros.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-ctzhi2.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-divsi3.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-ffshi2.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-lshrsi3.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-modsi3.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-parityhi2.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-popcounthi2.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-udivmodsi4.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-udivsi3.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2-umodsi3.c2
-rw-r--r--gcc/config/stormy16/stormy16-lib2.c86
-rw-r--r--gcc/config/stormy16/t-stormy1616
-rw-r--r--gcc/longlong.h22
18 files changed, 163 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c38e9705c73..ac3240c6639 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,29 @@
+2009-11-27 Nick Clifton <nickc@redhat.com>
+
+ * longlong.h (count_leading_zeros): Define macro for stormy16
+ target.
+ (COUNT_LEADING_ZEROS_0): Likewise.
+ * config/stormy16/stormy16-lib2.c: Arrange for separate
+ compilation of each function.
+ (__ffshi2): New function.
+ (__stormy16_count_leading_zeros): New function.
+ * config/stormy16/t-stormy16 (LIB2FUNCS_EXTRA): Use stub files to
+ compile each function into its own object file.
+ (stormy16-lib2-ashlsi3.c): New stub file.
+ (stormy16-lib2-ashrsi3.c): New stub file.
+ (stormy16-lib2-clzhi2.c): New stub file.
+ (stormy16-lib2-count-leading-zeros.c): New stub file.
+ (stormy16-lib2-ctzhi2.c): New stub file.
+ (stormy16-lib2-divsi3.c): New stub file.
+ (stormy16-lib2-ffshi2.c): New stub file.
+ (stormy16-lib2-lshrsi3.c): New stub file.
+ (stormy16-lib2-modsi3.c): New stub file.
+ (stormy16-lib2-parityhi2.c): New stub file.
+ (stormy16-lib2-popcounthi2.c): New stub file.
+ (stormy16-lib2-udivmodsi4.c): New stub file.
+ (stormy16-lib2-udivsi3.c): New stub file.
+ (stormy16-lib2-umodsi3.c): New stub file.
+
2009-11-27 Richard Henderson <rth@redhat.com>
* config/i386/sse.md (vec_interleave_highv16qi,
diff --git a/gcc/config/stormy16/stormy16-lib2-ashlsi3.c b/gcc/config/stormy16/stormy16-lib2-ashlsi3.c
new file mode 100644
index 00000000000..d6cabc6691c
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-ashlsi3.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_ASHLSI3
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-ashrsi3.c b/gcc/config/stormy16/stormy16-lib2-ashrsi3.c
new file mode 100644
index 00000000000..151e3d01cab
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-ashrsi3.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_ASHRSI3
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-clzhi2.c b/gcc/config/stormy16/stormy16-lib2-clzhi2.c
new file mode 100644
index 00000000000..066fdf13112
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-clzhi2.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_CLZHI2
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-count-leading-zeros.c b/gcc/config/stormy16/stormy16-lib2-count-leading-zeros.c
new file mode 100644
index 00000000000..1b98d30c18b
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-count-leading-zeros.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_COUNT_LEADING_ZEROS
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-ctzhi2.c b/gcc/config/stormy16/stormy16-lib2-ctzhi2.c
new file mode 100644
index 00000000000..c1497db952f
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-ctzhi2.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_CTZHI2
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-divsi3.c b/gcc/config/stormy16/stormy16-lib2-divsi3.c
new file mode 100644
index 00000000000..33c370d1c1f
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-divsi3.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_DIVSI3
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-ffshi2.c b/gcc/config/stormy16/stormy16-lib2-ffshi2.c
new file mode 100644
index 00000000000..4b629ddece8
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-ffshi2.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_FFSHI2
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-lshrsi3.c b/gcc/config/stormy16/stormy16-lib2-lshrsi3.c
new file mode 100644
index 00000000000..cd769ee6647
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-lshrsi3.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_LSHRSI3
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-modsi3.c b/gcc/config/stormy16/stormy16-lib2-modsi3.c
new file mode 100644
index 00000000000..587d0070d23
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-modsi3.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_MODSI3
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-parityhi2.c b/gcc/config/stormy16/stormy16-lib2-parityhi2.c
new file mode 100644
index 00000000000..1d128171a8b
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-parityhi2.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_PARITYHI2
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-popcounthi2.c b/gcc/config/stormy16/stormy16-lib2-popcounthi2.c
new file mode 100644
index 00000000000..f07d66873e6
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-popcounthi2.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_POPCOUNTHI2
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-udivmodsi4.c b/gcc/config/stormy16/stormy16-lib2-udivmodsi4.c
new file mode 100644
index 00000000000..d555e64c6d8
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-udivmodsi4.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_UDIVMODSI4
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-udivsi3.c b/gcc/config/stormy16/stormy16-lib2-udivsi3.c
new file mode 100644
index 00000000000..fdcd64a0ae0
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-udivsi3.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_UDIVSI3
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2-umodsi3.c b/gcc/config/stormy16/stormy16-lib2-umodsi3.c
new file mode 100644
index 00000000000..87921f2a196
--- /dev/null
+++ b/gcc/config/stormy16/stormy16-lib2-umodsi3.c
@@ -0,0 +1,2 @@
+#define XSTORMY16_UMODSI3
+#include "stormy16-lib2.c"
diff --git a/gcc/config/stormy16/stormy16-lib2.c b/gcc/config/stormy16/stormy16-lib2.c
index d5ab1c3e1bc..91c3c3dd2ca 100644
--- a/gcc/config/stormy16/stormy16-lib2.c
+++ b/gcc/config/stormy16/stormy16-lib2.c
@@ -75,7 +75,7 @@ extern int __clzhi2 (UHWtype);
extern int __ctzhi2 (UHWtype);
-
+#ifdef XSTORMY16_UDIVMODSI4
USItype
udivmodsi4 (USItype num, USItype den, word_type modwanted)
{
@@ -102,7 +102,9 @@ udivmodsi4 (USItype num, USItype den, word_type modwanted)
return num;
return res;
}
+#endif
+#ifdef XSTORMY16_DIVSI3
SItype
__divsi3 (SItype a, SItype b)
{
@@ -128,7 +130,9 @@ __divsi3 (SItype a, SItype b)
return res;
}
+#endif
+#ifdef XSTORMY16_MODSI3
SItype
__modsi3 (SItype a, SItype b)
{
@@ -151,19 +155,25 @@ __modsi3 (SItype a, SItype b)
return res;
}
+#endif
+#ifdef XSTORMY16_UDIVSI3
SItype
__udivsi3 (SItype a, SItype b)
{
return udivmodsi4 (a, b, 0);
}
+#endif
+#ifdef XSTORMY16_UMODSI3
SItype
__umodsi3 (SItype a, SItype b)
{
return udivmodsi4 (a, b, 1);
}
+#endif
+#ifdef XSTORMY16_ASHLSI3
SItype
__ashlsi3 (SItype a, SItype b)
{
@@ -177,7 +187,9 @@ __ashlsi3 (SItype a, SItype b)
a <<= 1;
return a;
}
+#endif
+#ifdef XSTORMY16_ASHRSI3
SItype
__ashrsi3 (SItype a, SItype b)
{
@@ -191,7 +203,9 @@ __ashrsi3 (SItype a, SItype b)
a >>= 1;
return a;
}
+#endif
+#ifdef XSTORMY16_LSHRSI3
USItype
__lshrsi3 (USItype a, USItype b)
{
@@ -205,9 +219,11 @@ __lshrsi3 (USItype a, USItype b)
a >>= 1;
return a;
}
+#endif
+#ifdef XSTORMY16_POPCOUNTHI2
/* Returns the number of set bits in X.
- FIXME: The return type really should be unsigned,
+ FIXME: The return type really should be "unsigned int"
but this is not how the builtin is prototyped. */
int
__popcounthi2 (UHWtype x)
@@ -219,9 +235,11 @@ __popcounthi2 (UHWtype x)
return ret;
}
+#endif
+#ifdef XSTORMY16_PARITYHI2
/* Returns the number of set bits in X, modulo 2.
- FIXME: The return type really should be unsigned,
+ FIXME: The return type really should be "unsigned int"
but this is not how the builtin is prototyped. */
int
@@ -232,32 +250,72 @@ __parityhi2 (UHWtype x)
x &= 0xf;
return (0x6996 >> x) & 1;
}
+#endif
+#ifdef XSTORMY16_CLZHI2
/* Returns the number of leading zero bits in X.
- FIXME: The return type really should be unsigned,
+ FIXME: The return type really should be "unsigned int"
but this is not how the builtin is prototyped. */
int
__clzhi2 (UHWtype x)
{
- if (x > 0xff)
- return 8 - __clz_tab[x >> 8];
- return 16 - __clz_tab[x];
+ return __stormy16_count_leading_zeros (x);
}
+#endif
+#ifdef XSTORMY16_CTZHI2
/* Returns the number of trailing zero bits in X.
- FIXME: The return type really should be unsigned,
- but this is not how the builtin is prototyped. */
+ FIXME: The return type really should be "signed int" since
+ ctz(0) returns -1, but this is not how the builtin is prototyped. */
int
__ctzhi2 (UHWtype x)
{
/* This is cunning. It converts X into a number with only the one bit
- set, the bit was the least significant bit in X. From this we can
- use the __clz_tab[] array to compute the number of trailing bits. */
+ set, the bit that was the least significant bit in X. From this we
+ can use the count_leading_zeros to compute the number of trailing
+ bits. */
x &= - x;
- if (x > 0xff)
- return __clz_tab[x >> 8] + 7;
- return __clz_tab[x] - 1;
+ return 15 - __stormy16_count_leading_zeros (x);
+}
+#endif
+
+#ifdef XSTORMY16_FFSHI2
+/* Returns one plus the index of the least significant 1-bit of X,
+ or if X is zero, returns zero. FIXME: The return type really
+ should be "unsigned int" but this is not how the builtin is
+ prototyped. */
+
+int
+__ffshi2 (UHWtype u)
+{
+ UHWtype count;
+
+ if (u == 0)
+ return 0;
+
+ return 16 - __stormy16_count_leading_zeros (u & - u);
+}
+#endif
+
+#ifdef XSTORMY16_COUNT_LEADING_ZEROS
+#undef unsigned
+/* Count the number of zero-bits from the most significant bit to the
+ first nonzero bit in VALUE. Returns 16 for VALUE == 0. Implemented
+ as a simple for loop in order to save space by removing the need for
+ the __clz_tab array. */
+
+unsigned int
+__stormy16_count_leading_zeros (unsigned int value)
+{
+ unsigned int i;
+ unsigned int c;
+
+ for (c = 0, i = 1 << 15; i; i >>= 1, c++)
+ if (i & value)
+ break;
+ return c;
}
+#endif /* XSTORMY16_COUNT_LEADING_ZEROS */
diff --git a/gcc/config/stormy16/t-stormy16 b/gcc/config/stormy16/t-stormy16
index 4e32c312aac..b103f88a1df 100644
--- a/gcc/config/stormy16/t-stormy16
+++ b/gcc/config/stormy16/t-stormy16
@@ -21,7 +21,21 @@
# SImode routines
LIB2FUNCS_EXTRA = \
- $(srcdir)/config/stormy16/stormy16-lib2.c
+ $(srcdir)/config/stormy16/stormy16-lib2-udivmodsi4.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-divsi3.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-modsi3.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-udivsi3.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-umodsi3.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-ashlsi3.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-ashrsi3.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-lshrsi3.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-popcounthi2.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-parityhi2.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-clzhi2.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-ctzhi2.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-ffshi2.c \
+ $(srcdir)/config/stormy16/stormy16-lib2-count-leading-zeros.c
+
# floating point emulation libraries
diff --git a/gcc/longlong.h b/gcc/longlong.h
index 11e70139957..e1f8b359881 100644
--- a/gcc/longlong.h
+++ b/gcc/longlong.h
@@ -1324,6 +1324,28 @@ UDItype __umulsidi3 (USItype, USItype);
#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
#endif /* __xtensa__ */
+#if defined xstormy16
+extern UHItype __stormy16_count_leading_zeros (UHItype);
+#define count_leading_zeros(count, x) \
+ do \
+ { \
+ UHItype size; \
+ \
+ /* We assume that W_TYPE_SIZE is a multiple of 16... */ \
+ for ((count) = 0, size = W_TYPE_SIZE; size; size -= 16) \
+ { \
+ UHItype c; \
+ \
+ c = __stormy16_count_leading_zeros ((x) >> (size - 16)); \
+ (count) += c; \
+ if (c != 16) \
+ break; \
+ } \
+ } \
+ while (0)
+#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
+#endif
+
#if defined (__z8000__) && W_TYPE_SIZE == 16
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %H1,%H5\n\tadc %H0,%H3" \