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]
Other format: [Raw text]

xstormy16: fix variable-length va_args


Most ports got fixed last year, stormy got missed.  No regressions.

Also still waiting on http://gcc.gnu.org/ml/gcc-patches/2003-05/msg00558.html

2003-05-08  DJ Delorie  <dj@redhat.com>

	* config/stormy16/stormy16.c (xstormy16_expand_builtin_va_arg): Fix
	to handle arguments for which MUST_PASS_IN_STACK is true (e.g.,
	variable-sized types).
	(xstormy16_function_arg): New.  Pass them that way too.
	* config/stormy16/stormy16-protos.h (xstormy16_function_arg): New.
	* config/stormy16/stormy16.h (FUNCTION_ARG): Call it.

Index: stormy16-protos.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/stormy16/stormy16-protos.h,v
retrieving revision 1.10
diff -p -2 -r1.10  stormy16-protos.h
*** stormy16-protos.h	6 May 2003 22:47:45 -0000	1.10
--- stormy16-protos.h	8 May 2003 20:10:19 -0000
*************** extern void	xstormy16_function_profiler 
*** 36,39 ****
--- 36,41 ----
  extern CUMULATIVE_ARGS xstormy16_function_arg_advance 
    PARAMS ((CUMULATIVE_ARGS, enum machine_mode, tree, int));
+ extern rtx xstormy16_function_arg
+   PARAMS ((CUMULATIVE_ARGS, enum machine_mode, tree, int));
  #  endif
  extern void    xstormy16_setup_incoming_varargs 
Index: stormy16.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/stormy16/stormy16.c,v
retrieving revision 1.40
diff -p -2 -r1.40  stormy16.c
*** stormy16.c	6 May 2003 22:47:45 -0000	1.40
--- stormy16.c	8 May 2003 20:10:19 -0000
*************** xstormy16_function_arg_advance (cum, mod
*** 1261,1264 ****
--- 1261,1279 ----
  }
  
+ rtx
+ xstormy16_function_arg (cum, mode, type, named)
+      CUMULATIVE_ARGS cum;
+      enum machine_mode mode;
+      tree type;
+      int named ATTRIBUTE_UNUSED;
+ {
+   if (mode == VOIDmode)
+     return const0_rtx;
+   if (MUST_PASS_IN_STACK (mode, type)
+       || cum + XSTORMY16_WORD_SIZE (type, mode) > NUM_ARGUMENT_REGISTERS)
+     return 0;
+   return gen_rtx_REG (mode, cum + 2);
+ }
+ 
  /* Do any needed setup for a variadic function.  CUM has not been updated
     for the last named argument which has type TYPE and mode MODE.  */
*************** xstormy16_expand_builtin_va_arg (valist,
*** 1355,1359 ****
    rtx lab_gotaddr, lab_fromstack;
    tree t;
!   int size, size_of_reg_args;
    tree size_tree, count_plus_size;
    rtx count_plus_size_rtx;
--- 1370,1374 ----
    rtx lab_gotaddr, lab_fromstack;
    tree t;
!   int size, size_of_reg_args, must_stack;
    tree size_tree, count_plus_size;
    rtx count_plus_size_rtx;
*************** xstormy16_expand_builtin_va_arg (valist,
*** 1365,1369 ****
    count = build (COMPONENT_REF, TREE_TYPE (f_count), valist, f_count);
  
!   size = PUSH_ROUNDING (int_size_in_bytes (type));
    size_tree = round_up (size_in_bytes (type), UNITS_PER_WORD);
    
--- 1380,1384 ----
    count = build (COMPONENT_REF, TREE_TYPE (f_count), valist, f_count);
  
!   must_stack = MUST_PASS_IN_STACK (TYPE_MODE (type), type);
    size_tree = round_up (size_in_bytes (type), UNITS_PER_WORD);
    
*************** xstormy16_expand_builtin_va_arg (valist,
*** 1375,1396 ****
    addr_rtx = gen_reg_rtx (Pmode);
  
!   count_plus_size = build (PLUS_EXPR, TREE_TYPE (count), count, size_tree);
!   count_plus_size_rtx = expand_expr (count_plus_size, NULL_RTX, HImode, EXPAND_NORMAL);
!   emit_cmp_and_jump_insns (count_plus_size_rtx, GEN_INT (size_of_reg_args),
! 			   GTU, const1_rtx, HImode, 1, lab_fromstack);
!   
!   t = build (PLUS_EXPR, ptr_type_node, base, count);
!   r = expand_expr (t, addr_rtx, Pmode, EXPAND_NORMAL);
!   if (r != addr_rtx)
!     emit_move_insn (addr_rtx, r);
! 
!   emit_jump_insn (gen_jump (lab_gotaddr));
!   emit_barrier ();
!   emit_label (lab_fromstack);
    
    /* Arguments larger than a word might need to skip over some
       registers, since arguments are either passed entirely in
       registers or entirely on the stack.  */
!   if (size > 2 || size < 0)
      {
        rtx lab_notransition = gen_label_rtx ();
--- 1390,1415 ----
    addr_rtx = gen_reg_rtx (Pmode);
  
!   if (!must_stack)
!     {
!       count_plus_size = build (PLUS_EXPR, TREE_TYPE (count), count, size_tree);
!       count_plus_size_rtx = expand_expr (count_plus_size, NULL_RTX, HImode, EXPAND_NORMAL);
!       emit_cmp_and_jump_insns (count_plus_size_rtx, GEN_INT (size_of_reg_args),
! 			       GTU, const1_rtx, HImode, 1, lab_fromstack);
!   
!       t = build (PLUS_EXPR, ptr_type_node, base, count);
!       r = expand_expr (t, addr_rtx, Pmode, EXPAND_NORMAL);
!       if (r != addr_rtx)
! 	emit_move_insn (addr_rtx, r);
! 
!       emit_jump_insn (gen_jump (lab_gotaddr));
!       emit_barrier ();
!       emit_label (lab_fromstack);
!     }
    
    /* Arguments larger than a word might need to skip over some
       registers, since arguments are either passed entirely in
       registers or entirely on the stack.  */
!   size = PUSH_ROUNDING (int_size_in_bytes (type));
!   if (size > 2 || size < 0 || must_stack)
      {
        rtx lab_notransition = gen_label_rtx ();
Index: stormy16.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/stormy16/stormy16.h,v
retrieving revision 1.74
diff -p -2 -r1.74  stormy16.h
*** stormy16.h	6 May 2003 22:47:45 -0000	1.74
--- stormy16.h	8 May 2003 20:10:20 -0000
*************** enum reg_class
*** 1246,1253 ****
     `REG_PARM_STACK_SPACE' is defined, the argument will be computed in the
     stack and then loaded into a register.  */
! #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED)				  \
!   ((MODE) == VOIDmode ? const0_rtx					  \
!    : (CUM) + XSTORMY16_WORD_SIZE (TYPE, MODE) > NUM_ARGUMENT_REGISTERS ? 0 \
!    : gen_rtx_REG (MODE, (CUM) + 2))
  
  /* Define this macro if the target machine has "register windows", so that the
--- 1246,1251 ----
     `REG_PARM_STACK_SPACE' is defined, the argument will be computed in the
     stack and then loaded into a register.  */
! #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
! 	xstormy16_function_arg (CUM, MODE, TYPE, NAMED)
  
  /* Define this macro if the target machine has "register windows", so that the


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