This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Building newlib SPU port with FSF gcc


Joel,

I tried building the latest newlib with the latest FSF gcc and
encountered a few compile time errors.

There are a few uses of Altivec style initializers still in the code.

There is a use of "vector" as a keyword which is implemented as a define
in spu_intrinsics.h, which is not included in that case.  It is better
to use "__vector".

Also, there is an issue with uses of size_t, which is defined as a long
int.  For certain intrinsics, like spu_splats(), a long type is
considered ambiguous, and the compiler will generate an error.  The
specification of the intrinsics, could be extended to handle long, and
I'll raise that as a possiblitiy with the 3C group.  But you might want
to fix the cases where it occurs anyway.

I've included a patch below which identifies the places which cause
problems.  

Trevor

Index: libgloss/spu/syscalls.c
===================================================================
RCS file: /cvs/src/src/libgloss/spu/syscalls.c,v
retrieving revision 1.4
diff -u -p -r1.4 syscalls.c
--- libgloss/spu/syscalls.c	30 Aug 2006 19:06:48 -0000	1.4
+++ libgloss/spu/syscalls.c	21 Nov 2006 02:40:23 -0000
@@ -38,7 +38,7 @@ _send_to_ppe (unsigned int signalcode, u
 
 	unsigned int	combined = ( ( opcode<<24 )&0xff000000 ) | ( ( unsigned int )data & 0x00ffffff );
 
-        vector unsigned int stopfunc = {
+        __vector unsigned int stopfunc = {
                 signalcode,     /* stop */
                 (unsigned int) combined,
                 0x4020007f,     /* nop */
Index: newlib/libc/machine/spu/memcpy.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/spu/memcpy.c,v
retrieving revision 1.3
diff -u -p -r1.3 memcpy.c
--- newlib/libc/machine/spu/memcpy.c	27 Oct 2006 23:02:00 -0000	1.3
+++ newlib/libc/machine/spu/memcpy.c	21 Nov 2006 02:40:24 -0000
@@ -91,7 +91,7 @@ void * memcpy(void * __restrict__ dest, 
   mask  = VEC_SPLAT_U8(-1);
   mask1 = spu_rlmaskqwbyte(mask, -doffset1);
   mask2 = spu_slqwbyte(mask, 16-doffset2);
-  mask3 = (vec_uchar16)spu_cmpgt(spu_splats(doffset1 + n), 15);
+  mask3 = (vec_uchar16)spu_cmpgt(spu_splats(doffset1 + (unsigned int)n), 15);
 
   *vDst++ = spu_sel(ddata, sdata, spu_and(mask1, spu_or(mask2, mask3)));
 
@@ -108,7 +108,7 @@ void * memcpy(void * __restrict__ dest, 
 
   /* Handle any trailing partial (destination) quadwords
    */
-  mask = spu_and((vec_uchar16)spu_cmpgt(spu_splats(n), 16), mask2);
+  mask = spu_and((vec_uchar16)spu_cmpgt(spu_splats((unsigned int)n), 16), mask2);
   *vDst = spu_sel(*vDst, spu_shuffle(sdata2, *vSrc, shuffle), mask);
 
   return (dest);
Index: newlib/libc/machine/spu/memmove.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/spu/memmove.c,v
retrieving revision 1.1
diff -u -p -r1.1 memmove.c
--- newlib/libc/machine/spu/memmove.c	27 Oct 2006 23:02:00 -0000	1.1
+++ newlib/libc/machine/spu/memmove.c	21 Nov 2006 02:40:24 -0000
@@ -65,7 +65,7 @@ void * memmove(void * __restrict__ dest,
   mask  = VEC_SPLAT_U8(-1);
   mask1 = spu_rlmaskqwbyte(mask, -doffset1);
   mask2 = spu_slqwbyte(mask, 16-doffset2);
-  mask3 = (vec_uchar16)spu_cmpgt(spu_splats(doffset1 + n), 15);
+  mask3 = (vec_uchar16)spu_cmpgt(spu_splats(doffset1 + (unsigned int)n), 15);
 
   vDst = (vec_uchar16 *)(dest);
 
@@ -123,7 +123,7 @@ void * memmove(void * __restrict__ dest,
     mask  = VEC_SPLAT_U8(-1);
     mask1 = spu_rlmaskqwbyte(mask, -doffset1);
     mask2 = spu_slqwbyte(mask, 16-doffset2);
-    mask3 = (vec_uchar16)spu_cmpgt(spu_splats(doffset1 + n), 15);
+    mask3 = (vec_uchar16)spu_cmpgt(spu_splats(doffset1 + (unsigned int)n), 15);
 
     *vDst++ = spu_sel(ddata, sdata, spu_and(mask1, spu_or(mask2, mask3)));
 
@@ -140,7 +140,7 @@ void * memmove(void * __restrict__ dest,
 
     /* Handle any trailing partial (destination) quadwords
      */
-    mask = spu_and((vec_uchar16)spu_cmpgt(spu_splats(n), 16), mask2);
+    mask = spu_and((vec_uchar16)spu_cmpgt(spu_splats((unsigned int)n), 16), mask2);
     *vDst = spu_sel(*vDst, spu_shuffle(sdata2, *vSrc, shuffle), mask);
 
   } else {
Index: newlib/libc/machine/spu/memset.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/spu/memset.c,v
retrieving revision 1.1
diff -u -p -r1.1 memset.c
--- newlib/libc/machine/spu/memset.c	27 Oct 2006 23:02:00 -0000	1.1
+++ newlib/libc/machine/spu/memset.c	21 Nov 2006 02:40:24 -0000
@@ -32,6 +32,7 @@
 */
 #include <spu_intrinsics.h>
 #include <stddef.h>
+#include "vec_literal.h"
 
 /* Fills the first n bytes of the memory area pointed to by s
  * with the constant byte c. Returns a pointer to the memory area s.
@@ -52,10 +53,10 @@ void * memset(void *s, int c, size_t n)
    */
   skip = (int)(s) & 15;
   if (skip) {
-    mask = spu_rlmaskqwbyte((vec_uchar16)(-1), 0-skip);
+    mask = spu_rlmaskqwbyte(VEC_SPLAT_U8(-1), 0-skip);
     cnt -= 16 - skip;
     if (cnt < 0) {
-      mask = spu_and(mask, spu_slqwbyte((vec_uchar16)(-1), (unsigned int)(-cnt)));
+      mask = spu_and(mask, spu_slqwbyte(VEC_SPLAT_U8(-1), (unsigned int)(-cnt)));
     }
     *vs = spu_sel(*vs, vc, mask);
     vs++;
@@ -82,7 +83,7 @@ void * memset(void *s, int c, size_t n)
   /* Handle any trailing partial quadwords
    */
   if (cnt > 0) {
-    mask = spu_slqwbyte((vec_uchar16)(-1), (unsigned int)(16-cnt));
+    mask = spu_slqwbyte(VEC_SPLAT_U8(-1), (unsigned int)(16-cnt));
     *vs = spu_sel(*vs, vc, mask);
   }
 
Index: newlib/libc/machine/spu/strchr.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/spu/strchr.c,v
retrieving revision 1.1
diff -u -p -r1.1 strchr.c
--- newlib/libc/machine/spu/strchr.c	27 Oct 2006 23:02:00 -0000	1.1
+++ newlib/libc/machine/spu/strchr.c	21 Nov 2006 02:40:24 -0000
@@ -32,6 +32,7 @@
 */
 #include <spu_intrinsics.h>
 #include <stddef.h>
+#include "vec_literal.h"
 
 /* Scans the string pointed to by s for the character c and
  * returns a pointer to the first occurance of c. If
@@ -51,7 +52,7 @@ char *strchr(const char *s, int c)
   ptr = (vec_uchar16 *)s;
 
   skip = (unsigned int)(ptr) & 15;
-  mask = spu_rlmask((vec_uint4)(0xFFFF), -skip);
+  mask = spu_rlmask(VEC_SPLAT_U32(0xFFFF), -skip);
 
   vc = spu_splats((unsigned char)(c));
 
Index: newlib/libc/machine/spu/strncat.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/spu/strncat.c,v
retrieving revision 1.1
diff -u -p -r1.1 strncat.c
--- newlib/libc/machine/spu/strncat.c	27 Oct 2006 23:02:00 -0000	1.1
+++ newlib/libc/machine/spu/strncat.c	21 Nov 2006 02:40:24 -0000
@@ -55,7 +55,7 @@ char * strncat(char * __restrict__ dest,
   /* Copy the src image until either the src string terminates
    * or n characters are copied.
    */
-  N = spu_promote(n, 0);
+  N = spu_promote((unsigned int)n, 0);
 
   /* Determine the string length, not including termination character,
    * clamped to n characters.
@@ -71,7 +71,7 @@ char * strncat(char * __restrict__ dest,
   cnt = spu_cntlz(spu_promote(cmp, 0));
   len = spu_extract(cnt, 0) - (skip + 16);
 
-  gt = spu_cmpgt(spu_promote(len, 0), N);
+  gt = spu_cmpgt(spu_promote((unsigned int)len, 0), N);
 
   while (spu_extract(spu_andc(spu_cmpeq(cnt, 32), gt), 0)) {
     data = *ptr++;
@@ -79,12 +79,12 @@ char * strncat(char * __restrict__ dest,
     cnt  = spu_cntlz(spu_gather(spu_cmpeq(data, 0)));
     len += spu_extract(cnt, 0);
 
-    gt = spu_cmpgt(spu_promote(len, 0), N);
+    gt = spu_cmpgt(spu_promote((unsigned int)len, 0), N);
   }
 
   /* len = MIN(len, n)
    */
-  len = spu_extract(spu_sel(spu_promote(len, 0), N, gt), 0);
+  len = spu_extract(spu_sel(spu_promote((unsigned int)len, 0), N, gt), 0);
 
   /* Perform a memcpy of the resulting length
    */
Index: newlib/libc/machine/spu/strncpy.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/spu/strncpy.c,v
retrieving revision 1.1
diff -u -p -r1.1 strncpy.c
--- newlib/libc/machine/spu/strncpy.c	27 Oct 2006 23:02:00 -0000	1.1
+++ newlib/libc/machine/spu/strncpy.c	21 Nov 2006 02:40:24 -0000
@@ -45,7 +45,7 @@ char * strncpy(char * __restrict__ dest,
   vec_uchar16 *ptr, data;
   vec_uint4 cnt, gt, N;
 
-  N = spu_promote(n, 0);
+  N = spu_promote((unsigned int)n, 0);
 
   /* Determine the string length, including termination character,
    * clamped to n characters.
@@ -61,7 +61,7 @@ char * strncpy(char * __restrict__ dest,
   cnt = spu_cntlz(spu_promote(cmp, 0));
   len = spu_extract(cnt, 0) - (skip + 15);
 
-  gt = spu_cmpgt(spu_promote(len, 0), N);
+  gt = spu_cmpgt(spu_promote((unsigned int)len, 0), N);
 
   while (spu_extract(spu_andc(spu_cmpeq(cnt, 32), gt), 0)) {
     data = *ptr++;
@@ -69,12 +69,12 @@ char * strncpy(char * __restrict__ dest,
     cnt  = spu_cntlz(spu_gather(spu_cmpeq(data, 0)));
     len += spu_extract(cnt, 0);
 
-    gt = spu_cmpgt(spu_promote(len, 0), N);
+    gt = spu_cmpgt(spu_promote((unsigned int)len, 0), N);
   }
 
   /* len = MIN(len, n)
    */
-  len = spu_extract(spu_sel(spu_promote(len, 0), N, gt), 0);
+  len = spu_extract(spu_sel(spu_promote((unsigned int)len, 0), N, gt), 0);
 
   /* Perform a memcpy of the resulting length
    */
Index: newlib/libc/machine/spu/strrchr.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/spu/strrchr.c,v
retrieving revision 1.1
diff -u -p -r1.1 strrchr.c
--- newlib/libc/machine/spu/strrchr.c	27 Oct 2006 23:02:00 -0000	1.1
+++ newlib/libc/machine/spu/strrchr.c	21 Nov 2006 02:40:24 -0000
@@ -52,7 +52,7 @@ char * strrchr(const char *s, int c)
   ptr = (vec_uchar16 *)s;
 
   nskip = -((unsigned int)(ptr) & 15);
-  mask = spu_rlmask((vec_uint4)(0xFFFF), nskip);
+  mask = spu_rlmask(VEC_SPLAT_U32(0xFFFF), nskip);
 
   vc = spu_splats((unsigned char)(c));
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]