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: mn10200


Nothing tricky here.  I didn't build the whole toolchain
so I could test on the simulator.


r~



	* mn10200.c (mn10200_va_arg): New.
	* mn10200.h (EXPAND_BUILTIN_VA_ARG): New.

Index: mn10200/mn10200.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/mn10200/mn10200.c,v
retrieving revision 1.6
diff -c -p -d -r1.6 mn10200.c
*** mn10200.c	1998/12/16 21:10:14	1.6
--- mn10200.c	1999/07/28 08:32:56
*************** function_arg_partial_nregs (cum, mode, t
*** 1436,1441 ****
--- 1436,1478 ----
    return (nregs * UNITS_PER_WORD - cum->nbytes) / UNITS_PER_WORD;
  }
  
+ rtx
+ mn10200_va_arg (valist, type)
+      tree valist, type;
+ {
+   HOST_WIDE_INT align, rsize;
+   tree t, ptr, pptr;
+ 
+   /* Compute the rounded size of the type.  */
+   align = PARM_BOUNDARY / BITS_PER_UNIT;
+   rsize = (((int_size_in_bytes (type) + align - 1) / align) * align);
+ 
+   t = build (POSTINCREMENT_EXPR, TREE_TYPE (valist), valist, 
+ 	     build_int_2 ((rsize > 8 ? 4 : rsize), 0));
+   TREE_SIDE_EFFECTS (t) = 1;
+ 
+   ptr = build_pointer_type (type);
+ 
+   /* "Large" types are passed by reference.  */
+   if (rsize > 8)
+     {
+       pptr = build_pointer_type (ptr);
+       t = build1 (NOP_EXPR, pptr, t);
+       TREE_SIDE_EFFECTS (t) = 1;
+ 
+       t = build1 (INDIRECT_REF, ptr, t);
+       TREE_SIDE_EFFECTS (t) = 1;
+     }
+   else
+     {
+       t = build1 (NOP_EXPR, ptr, t);
+       TREE_SIDE_EFFECTS (t) = 1;
+     }
+ 
+   /* Calculate!  */
+   return expand_expr (t, NULL_RTX, Pmode, EXPAND_NORMAL);
+ }
+ 
  char *
  output_tst (operand, insn)
       rtx operand, insn;
Index: mn10200/mn10200.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/mn10200/mn10200.h,v
retrieving revision 1.12
diff -c -p -d -r1.12 mn10200.h
*** mn10200.h	1999/03/08 20:40:04	1.12
--- mn10200.h	1999/07/28 08:32:57
*************** extern struct rtx_def *function_arg();
*** 508,513 ****
--- 508,517 ----
  #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
    function_arg (&CUM, MODE, TYPE, NAMED)
  
+ /* Implement `va_arg'.  */
+ extern struct rtx_def *mn10200_va_arg();
+ #define EXPAND_BUILTIN_VA_ARG(valist, type) \
+   mn10200_va_arg (valist, type)
  
  /* For "large" items, we pass them by invisible reference, and the
     callee is responsible for copying the data item if it might be


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