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]

PowerPC variable-sized types passed by reference


	This patch fixes a c-torture test case 20020412-1 on AIX, Darwin,
and PPC64 Linux.

David

        * config/rs6000/rs6000.c (function_arg_pass_by_reference):
        Return true for variable sized types.
        (rs6000_va_arg): Handle variable sized types passed by reference
        on non-SVR4 ABI.

Index: rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.418
diff -c -p -r1.418 rs6000.c
*** rs6000.c	28 Jan 2003 18:08:54 -0000	1.418
--- rs6000.c	29 Jan 2003 17:35:15 -0000
*************** function_arg_partial_nregs (cum, mode, t
*** 3314,3320 ****
     the argument itself.  The pointer is passed in whatever way is
     appropriate for passing a pointer to that type.
  
!    Under V.4, structures and unions are passed by reference.  */
  
  int
  function_arg_pass_by_reference (cum, mode, type, named)
--- 3314,3323 ----
     the argument itself.  The pointer is passed in whatever way is
     appropriate for passing a pointer to that type.
  
!    Under V.4, structures and unions are passed by reference.
! 
!    As an extension to all ABIs, variable sized types are passed by
!    reference.  */
  
  int
  function_arg_pass_by_reference (cum, mode, type, named)
*************** function_arg_pass_by_reference (cum, mod
*** 3332,3339 ****
  
        return 1;
      }
! 
!   return 0;
  }
  
  /* Perform any needed actions needed for a function that is receiving a
--- 3335,3341 ----
  
        return 1;
      }
!   return type && int_size_in_bytes (type) <= 0;
  }
  
  /* Perform any needed actions needed for a function that is receiving a
*************** rs6000_va_arg (valist, type)
*** 3569,3575 ****
    rtx lab_false, lab_over, addr_rtx, r;
  
    if (DEFAULT_ABI != ABI_V4)
!     return std_expand_builtin_va_arg (valist, type);
  
    f_gpr = TYPE_FIELDS (TREE_TYPE (va_list_type_node));
    f_fpr = TREE_CHAIN (f_gpr);
--- 3571,3598 ----
    rtx lab_false, lab_over, addr_rtx, r;
  
    if (DEFAULT_ABI != ABI_V4)
!     {
!       /* Variable sized types are passed by reference.  */
!       if (int_size_in_bytes (type) <= 0)
! 	{
! 	  u = build_pointer_type (type);
! 
! 	  /* Args grow upward.  */
! 	  t = build (POSTINCREMENT_EXPR, TREE_TYPE (valist), valist,
! 		     build_int_2 (POINTER_SIZE / BITS_PER_UNIT, 0));
! 	  TREE_SIDE_EFFECTS (t) = 1;
! 
! 	  t = build1 (NOP_EXPR, build_pointer_type (u), t);
! 	  TREE_SIDE_EFFECTS (t) = 1;
! 
! 	  t = build1 (INDIRECT_REF, u, t);
! 	  TREE_SIDE_EFFECTS (t) = 1;
! 
! 	  return expand_expr (t, NULL_RTX, VOIDmode, EXPAND_NORMAL);
! 	}
!       else
! 	return std_expand_builtin_va_arg (valist, type);
!     }
  
    f_gpr = TYPE_FIELDS (TREE_TYPE (va_list_type_node));
    f_fpr = TREE_CHAIN (f_gpr);


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