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


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

va_list: mn10300


I'm a bit curious why you're using __builtin_saveregs instead
of setup_incoming_varargs.  I'm guessing that would make
current_function_internal_arg_pointer go away and things 
generally cleaner.  I'm also guessing it is the way it is
because pa does it this way.  ;-)

I didn't get to test this on the sim because there's something
broken 64-bit-wise.  I got prologue insns like `add 4294967296,sp'.
I could have just fallen back to an x86 box but didn't.


r~


	* mn10300.c (mn10300_builtin_saveregs): Use get_varargs_alias_set
	and tag the spill mems.
	(mn10300_va_start): New.
	(mn10300_va_arg): New.
	* mn10300.h (EXPAND_BUILTIN_VA_START): New.
	(EXPAND_BUILTIN_VA_ARG): New.
	
Index: config/mn10300/mn10300.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/mn10300/mn10300.c,v
retrieving revision 1.15
diff -c -p -d -r1.15 mn10300.c
*** mn10300.c	1999/07/26 01:21:57	1.15
--- mn10300.c	1999/07/28 08:36:19
*************** initial_offset (from, to)
*** 629,655 ****
  rtx
  mn10300_builtin_saveregs ()
  {
!   rtx offset;
    tree fntype = TREE_TYPE (current_function_decl);
    int argadj = ((!(TYPE_ARG_TYPES (fntype) != 0
                     && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
                         != void_type_node)))
                  ? UNITS_PER_WORD : 0);
  
    if (argadj)
      offset = plus_constant (current_function_arg_offset_rtx, argadj);
    else
      offset = current_function_arg_offset_rtx;
  
!   emit_move_insn (gen_rtx (MEM, SImode, current_function_internal_arg_pointer),
! 		  gen_rtx (REG, SImode, 0));
!   emit_move_insn (gen_rtx (MEM, SImode,
! 			   plus_constant
! 			     (current_function_internal_arg_pointer, 4)),
! 		  gen_rtx (REG, SImode, 1));
    return copy_to_reg (expand_binop (Pmode, add_optab,
  				    current_function_internal_arg_pointer,
  				    offset, 0, 0, OPTAB_LIB_WIDEN));
  }
  
  /* Return an RTX to represent where a value with mode MODE will be returned
--- 629,708 ----
  rtx
  mn10300_builtin_saveregs ()
  {
!   rtx offset, mem;
    tree fntype = TREE_TYPE (current_function_decl);
    int argadj = ((!(TYPE_ARG_TYPES (fntype) != 0
                     && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
                         != void_type_node)))
                  ? UNITS_PER_WORD : 0);
+   int set = get_varargs_alias_set ();
  
    if (argadj)
      offset = plus_constant (current_function_arg_offset_rtx, argadj);
    else
      offset = current_function_arg_offset_rtx;
  
!   mem = gen_rtx_MEM (SImode, current_function_internal_arg_pointer);
!   MEM_ALIAS_SET (mem) = set;
!   emit_move_insn (mem, gen_rtx_REG (SImode, 0));
! 
!   mem = gen_rtx_MEM (SImode,
! 		     plus_constant (current_function_internal_arg_pointer, 4));
!   MEM_ALIAS_SET (mem) = set;
!   emit_move_insn (mem, gen_rtx_REG (SImode, 1));
! 
    return copy_to_reg (expand_binop (Pmode, add_optab,
  				    current_function_internal_arg_pointer,
  				    offset, 0, 0, OPTAB_LIB_WIDEN));
+ }
+ 
+ void
+ mn10300_va_start (stdarg_p, valist, nextarg)
+      int stdarg_p;
+      tree valist;
+      rtx nextarg;
+ {
+   if (stdarg_p)
+     nextarg = expand_builtin_saveregs ();
+ 
+   std_expand_builtin_va_start (stdarg_p, valist, nextarg);
+ }
+ 
+ rtx
+ mn10300_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);
  }
  
  /* Return an RTX to represent where a value with mode MODE will be returned
Index: config/mn10300/mn10300.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/mn10300/mn10300.h,v
retrieving revision 1.18
diff -c -p -d -r1.18 mn10300.h
*** mn10300.h	1999/07/26 01:21:57	1.18
--- mn10300.h	1999/07/28 08:36:19
*************** extern struct rtx_def *function_arg ();
*** 472,478 ****
  
  #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
    function_arg_partial_nregs (&CUM, MODE, TYPE, NAMED)
- 
  
  #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED)		\
    ((TYPE) && int_size_in_bytes (TYPE) > 8)
--- 472,477 ----
*************** extern struct rtx_def *function_arg ();
*** 571,576 ****
--- 570,585 ----
  
  extern struct rtx_def *mn10300_builtin_saveregs ();
  #define EXPAND_BUILTIN_SAVEREGS() mn10300_builtin_saveregs ()
+ 
+ /* Implement `va_start' for varargs and stdarg.  */
+ extern void mn10300_va_start();
+ #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \
+   mn10300_va_start (stdarg, valist, nextarg)
+ 
+ /* Implement `va_arg'.  */
+ extern struct rtx_def *mn10300_va_arg();
+ #define EXPAND_BUILTIN_VA_ARG(valist, type) \
+   mn10300_va_arg (valist, type)
  
  /* Addressing modes, and classification of registers for them.  */
  

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