This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

va_list: pyr and spur


The pyramid port won't build, and spur doesn't show up in configure.in
even commented out.  Their varargs implementations predate stdarg.h,
and the pyramid version never worked for anything except integers.

I've created stub functions in the appropriate C files and copied the
relevant bits from the va-foo.h files so that there will be something
left for a port archeologist to find someday.


r~


        * pyr/pyr.c (pyr_build_va_list, pyr_va_start, pyr_va_arg): New stubs.
        * spur/spur.c (spur_build_va_list, spur_va_start): New stubs.
        (spur_va_arg): New stub.

        * configure.in: Comment out pyramid.

Index: pyr/pyr.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/pyr/pyr.c,v
retrieving revision 1.4
diff -c -p -d -r1.4 pyr.c
*** pyr.c	1999/08/09 14:00:09	1.4
--- pyr.c	1999/09/06 00:33:37
*************** forget_cc_if_dependent (op)
*** 856,858 ****
--- 856,955 ----
    if (cc_status.value2 && reg_overlap_mentioned_p (op, cc_status.value2))
      cc_status.value2 = 0;
  }
+ 
+ /* ??? None of the original definitions ever worked for stdarg.h, or
+    even for structs or float arguments.   Quoting bits of the old 
+    va-pyr.h for historical interest.  */
+ 
+ /**
+  *
+  * 	Varargs for PYR/GNU CC
+  *
+  * WARNING -- WARNING -- DANGER
+  *
+  * The code in this file implements varargs for gcc on a pyr in
+  * a way that is compatible with code compiled by the Pyramid Technology
+  * C compiler.
+  * As such, it depends strongly on the Pyramid conventions for
+  * parameter passing.ct and independent implementation. 
+  * These (somewhat bizarre) parameter-passing conventions are described
+  * in the ``OSx Operating System Porting Guide''.
+  * 
+  * A quick summary is useful:
+  * 12 of the 48 register-windowed regs available for
+  * parameter passing.  Parameters of a function call that are eligible
+  * to be passed in registers are assigned registers from TR0/PR0 onwards;
+  * all other arguments are passed on the stack.
+  * Structure and union parameters are *never* passed in registers,
+  * even if they are small enough to fit.  They are always passed on
+  * the stack.
+  *
+  * Double-sized parameters cannot be passed in TR11, because
+  * TR12 is not used for passing parameters.  If, in the absence of this
+  * rule, a double-sized param would have been passed in TR11,
+  * that parameter is passed on the stack and no parameters are
+  * passed in TR11.
+  * 
+  * It is only known to work for passing 32-bit integer quantities
+  * (ie chars, shorts, ints/enums, longs), doubles, or pointers. 
+  * Passing structures on a Pyramid via varargs is a loser.
+  * Passing an object larger than 8 bytes on a pyramid via varargs may
+  * also be a loser.
+  * 
+  */
+ 
+ tree
+ pyr_build_va_list ()
+ {
+ typedef struct __va_regs {
+       __voidptr __stackp,__regp,__count;
+       __voidptr __pr0,__pr1,__pr2,__pr3,__pr4,__pr5,__pr6,__pr7,__pr8,__pr9,__pr10,__pr11;
+   } __va_regs;
+ 
+ typedef __va_regs __va_buf;
+ typedef __va_buf __gnuc_va_list;
+ }
+ 
+ void
+ pyr_va_start (stdarg_p, valist, nextarg)
+      int stdarg_p;
+      tree valist;
+      rtx nextarg ATTRIBUTE_UNUSED;
+ {
+ #define va_alist \
+   __va0,__va1,__va2,__va3,__va4,__va5,__va6,__va7,__va8,__va9,__va10,__va11, \
+  __builtin_va_alist
+ 
+ /* The ... causes current_function_varargs to be set in cc1.  */
+ #define va_dcl __voidptr va_alist; __va_ellipsis
+ 
+ 
+ /* __asm ("rcsp %0" : "=r" ( _AP [0]));*/
+ 
+ #define va_start(_AP)  \
+   _AP =  ((struct __va_regs) {						\
+    &(_AP.__pr0), (void*)&__builtin_va_alist, (void*)0,			\
+         __va0,__va1,__va2,__va3,__va4,__va5,				\
+ 	__va6,__va7,__va8,__va9,__va10,__va11})
+ 
+ }
+ 
+ rtx
+ pyr_va_arg (valist, type)
+      tree valist, type;
+ {
+ #define va_arg(_AP, _MODE)	\
+ __extension__								\
+ (*({__voidptr *__ap = (__voidptr*)&_AP;					\
+   register int __size = sizeof (_MODE);					\
+   register int __onstack =						\
+ 	  (__size > 8 || ( (int)(__ap[2]) > 11) ||			\
+ 	    (__size==8 && (int)(__ap[2])==11));				\
+   register int* __param_addr =  ((int*)((__ap) [__onstack]));		\
+ 									\
+   ((void *)__ap[__onstack])+=__size;					\
+     if (__onstack==0 || (int)(__ap[2])==11)				\
+       __ap[2]+= (__size >> 2);						\
+   (( _MODE *) (void *) __param_addr);					\
+ }))
+ }
Index: spur/spur.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/spur/spur.c,v
retrieving revision 1.4
diff -c -p -d -r1.4 spur.c
*** spur.c	1999/08/24 12:05:08	1.4
--- spur.c	1999/09/06 00:33:37
*************** big_immediate_operand (op, mode)
*** 325,327 ****
--- 325,386 ----
  {
    return (GET_CODE (op) == CONST_INT);
  }
+ 
+ /* ??? None of the original definitions ever worked for stdarg.h, and
+    the port never updated for gcc2.  Quoting bits of the old va-spur.h
+    for historical interest.  */
+ 
+ tree
+ spur_build_va_list ()
+ {
+   typedef struct {
+     int __pnt;
+     char *__regs;
+     char *__stack;
+   } va_list;
+ }
+ 
+ void
+ spur_va_start (stdarg_p, valist, nextarg)
+      int stdarg_p;
+      tree valist;
+      rtx nextarg ATTRIBUTE_UNUSED;
+ {
+ struct __va_struct { char __regs[20]; };
+ 
+ #define va_alist __va_regs, __va_stack
+ #define va_dcl struct __va_struct __va_regs; int __va_stack; 
+ 
+ #define va_start(pvar) \
+      ((pvar).__pnt = 0, (pvar).__regs = __va_regs.__regs, \
+       (pvar).__stack = (char *) &__va_stack)
+ }
+ 
+ rtx
+ spur_va_arg (valist, type)
+      tree valist, type;
+ {
+ #define va_arg(pvar,type)						   \
+ __extension__								   \
+     (*({  type *__va_result;						   \
+         if ((pvar).__pnt >= 20) {					   \
+            __va_result = ( (type *) ((pvar).__stack + (pvar).__pnt - 20)); \
+ 	   (pvar).__pnt += (sizeof(type) + 7) & ~7;			   \
+ 	}								   \
+ 	else if ((pvar).__pnt + sizeof(type) > 20) {			   \
+ 	   __va_result = (type *) (pvar).__stack;			   \
+ 	   (pvar).__pnt = 20 + ( (sizeof(type) + 7) & ~7);		   \
+ 	}								   \
+ 	else if (sizeof(type) == 8) {					   \
+ 	   union {double d; int i[2];} __u;				   \
+ 	   __u.i[0] = *(int *) ((pvar).__regs + (pvar).__pnt);		   \
+ 	   __u.i[1] = *(int *) ((pvar).__regs + (pvar).__pnt + 4);	   \
+ 	   __va_result = (type *) &__u;					   \
+ 	   (pvar).__pnt += 8;						   \
+ 	}								   \
+ 	else {								   \
+ 	   __va_result = (type *) ((pvar).__regs + (pvar).__pnt);	   \
+ 	   (pvar).__pnt += (sizeof(type) + 3) & ~3;			   \
+ 	}								   \
+ 	__va_result; }))
+ }
Index: configure.in
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/configure.in,v
retrieving revision 1.279
diff -c -p -d -r1.279 configure.in
*** configure.in	1999/08/29 09:20:15	1.279
--- configure.in	1999/09/06 00:36:50
*************** changequote([,])dnl
*** 2819,2829 ****
  	ns32k-*-openbsd*)
  		# Nothing special
  		;;
! 	pyramid-*-*)
! 		cpu_type=pyr
! 		xmake_file=pyr/x-pyr
! 		use_collect2=yes
! 		;;
  	romp-*-aos*)
  		use_collect2=yes
  		;;
--- 2819,2830 ----
  	ns32k-*-openbsd*)
  		# Nothing special
  		;;
! # This has not been updated to GCC 2.
! #	pyramid-*-*)
! #		cpu_type=pyr
! #		xmake_file=pyr/x-pyr
! #		use_collect2=yes
! #		;;
  	romp-*-aos*)
  		use_collect2=yes
  		;;


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