va_list: pa

Richard Henderson rth@cygnus.com
Wed Jul 28 01:49:00 GMT 1999


Remarkably straightforward for something having to do with hppa.  ;-)

I just eyeballed the output.  Last I checked, none of the hp's here
ran automounters, which means I'd have to copy my source tree somewhere
else.  Being lazy, I'm happy to let you put that big new box to work
running the test suite.


r~



	* pa.c (hppa_builtin_saveregs):  Use get_varargs_alias_set
	and tag the spill mems.
	(hppa_va_start): New.
	(hppa_va_arg): New.
	* pa.h (EXPAND_BUILTIN_VA_START): New.
	(EXPAND_BUILTIN_VA_ARG): New.

Index: config/pa/pa.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/pa/pa.c,v
retrieving revision 1.43
diff -c -p -d -r1.43 pa.c
*** pa.c	1999/07/26 01:21:57	1.43
--- pa.c	1999/07/28 08:42:14
*************** hppa_builtin_saveregs ()
*** 4282,4287 ****
--- 4282,4288 ----
    dest = gen_rtx_MEM (BLKmode,
  		      plus_constant (current_function_internal_arg_pointer,
  				     -16));
+   MEM_ALIAS_SET (dest) = get_varargs_alias_set ();
    move_block_from_reg (23, dest, 4, 4 * UNITS_PER_WORD);
  
    /* move_block_from_reg will emit code to store the argument registers
*************** hppa_builtin_saveregs ()
*** 4306,4311 ****
--- 4307,4379 ----
  				    current_function_internal_arg_pointer,
  				    offset, 0, 0, OPTAB_LIB_WIDEN));
  }
+ 
+ void
+ hppa_va_start (stdarg_p, valist, nextarg)
+      int stdarg_p;
+      tree valist;
+      rtx nextarg;
+ {
+   nextarg = expand_builtin_saveregs ();
+   std_expand_builtin_va_start (1, valist, nextarg);
+ }
+ 
+ rtx
+ hppa_va_arg (valist, type)
+      tree valist, type;
+ {
+   HOST_WIDE_INT align, size, ofs;
+   tree t, ptr, pptr;
+ 
+   /* Compute the rounded size of the type.  */
+   align = PARM_BOUNDARY / BITS_PER_UNIT;
+   size = int_size_in_bytes (type);
+ 
+   ptr = build_pointer_type (type);
+ 
+   /* "Large" types are passed by reference.  */
+   if (size > 8)
+     {
+       t = build (PREDECREMENT_EXPR, TREE_TYPE (valist), valist, 
+ 		 build_int_2 (POINTER_SIZE / BITS_PER_UNIT, 0));
+       TREE_SIDE_EFFECTS (t) = 1;
+ 
+       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 = build (PLUS_EXPR, TREE_TYPE (valist), valist,
+ 		 build_int_2 (-size, -1));
+ 
+       /* ??? Copied from va-pa.h, but we probably don't need to align
+ 	 to word size, since we generate and preserve that invariant.  */
+       t = build (BIT_AND_EXPR, TREE_TYPE (valist), t,
+ 		 build_int_2 ((size > 4 ? -8 : -4), -1));
+ 
+       t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, t);
+       TREE_SIDE_EFFECTS (t) = 1;
+       
+       ofs = (8 - size) % 4;
+       if (ofs)
+ 	{
+ 	  t = build (PLUS_EXPR, TREE_TYPE (valist), t, build_int_2 (ofs, 0));
+ 	  TREE_SIDE_EFFECTS (t) = 1;
+ 	}
+ 
+       t = build1 (NOP_EXPR, ptr, t);
+       TREE_SIDE_EFFECTS (t) = 1;
+     }
+ 
+   /* Calculate!  */
+   return expand_expr (t, NULL_RTX, Pmode, EXPAND_NORMAL);
+ }
+ 
+ 
  
  /* This routine handles all the normal conditional branch sequences we
     might need to generate.  It handles compare immediate vs compare
Index: config/pa/pa.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/pa/pa.h,v
retrieving revision 1.54
diff -c -p -d -r1.54 pa.h
*** pa.h	1999/07/26 01:21:58	1.54
--- pa.h	1999/07/28 08:42:14
*************** extern union tree_node *current_function
*** 1219,1224 ****
--- 1219,1235 ----
  extern struct rtx_def *hppa_builtin_saveregs ();
  #define EXPAND_BUILTIN_SAVEREGS() hppa_builtin_saveregs ()
  
+ /* Implement `va_start' for varargs and stdarg.  */
+ 
+ extern void hppa_va_start();
+ #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
+   hppa_va_start (stdarg, valist, nextarg)
+ 
+ /* Implement `va_arg'.  */
+ 
+ extern struct rtx_def *hppa_va_arg();
+ #define EXPAND_BUILTIN_VA_ARG(valist, type) \
+   hppa_va_arg (valist, type)
  
  /* Addressing modes, and classification of registers for them. 
  


More information about the Gcc-patches mailing list