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]

gimple va_arg by-reference helper


Quite a few targets want standard behaviour modulo pass-by-reference.

It would be nice if we could use FUNCTION_ARG_PASS_BY_REFERENCE in
the standard gimplifier, instead of having to replicate this logic
in all the backends, but we don't have a valid CUMULATIVE_ARGS struct.

I'd be surprised if we couldn't just remove the CUM argument to
FUNCTION_ARG_PASS_BY_REFERENCE, but I havn't looked into it.


r~


        * builtins.c (ind_gimplify_va_arg_expr): New.
        * tree.h (ind_gimplify_va_arg_expr): Declare.
        * config/arc/arc.c (arc_gimplify_va_arg_expr): Use it.

Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.350
diff -c -p -d -r1.350 builtins.c
*** builtins.c	8 Jul 2004 17:40:14 -0000	1.350
--- builtins.c	8 Jul 2004 21:59:11 -0000
*************** std_gimplify_va_arg_expr (tree valist, t
*** 4549,4554 ****
--- 4549,4565 ----
    return build_fold_indirect_ref (addr);
  }
  
+ /* Like std_gimplify_va_arg_expr, but uses pass-by-reference.  */
+  
+ tree
+ ind_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p)
+ {
+   tree t;
+   t = build_pointer_type (type);
+   t = std_gimplify_va_arg_expr (valist, t, pre_p, post_p);
+   return build_fold_indirect_ref (t);
+ }
+ 
  /* Return a dummy expression of type TYPE in order to keep going after an
     error.  */
  
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.548
diff -c -p -d -r1.548 tree.h
*** tree.h	8 Jul 2004 17:40:20 -0000	1.548
--- tree.h	8 Jul 2004 21:59:11 -0000
*************** extern tree strip_float_extensions (tree
*** 3434,3439 ****
--- 3434,3440 ----
  extern tree simplify_builtin (tree, int);
  extern tree c_strlen (tree, int);
  extern tree std_gimplify_va_arg_expr (tree, tree, tree *, tree *);
+ extern tree ind_gimplify_va_arg_expr (tree, tree, tree *, tree *);
  
  /* In convert.c */
  extern tree strip_float_extensions (tree);
Index: config/arc/arc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arc/arc.c,v
retrieving revision 1.55
diff -c -p -d -r1.55 arc.c
*** config/arc/arc.c	8 Jul 2004 21:10:16 -0000	1.55
--- config/arc/arc.c	8 Jul 2004 21:59:12 -0000
*************** arc_gimplify_va_arg_expr (tree valist, t
*** 2299,2309 ****
       than 8 bytes are passed by reference.  */
  
    if (AGGREGATE_TYPE_P (type) || int_size_in_bytes (type) > 8)
!     {
!       tree type_ptr = build_pointer_type (type);
!       tree addr = std_gimplify_va_arg_expr (valist, type_ptr, pre_p, post_p);
!       return build_fold_indirect_ref (addr);
!     }
  
    return std_gimplify_va_arg_expr (valist, type, pre_p, post_p);
  }
--- 2299,2305 ----
       than 8 bytes are passed by reference.  */
  
    if (AGGREGATE_TYPE_P (type) || int_size_in_bytes (type) > 8)
!     return ind_gimplify_va_arg_expr (valist, type, pre_p, post_p);
  
    return std_gimplify_va_arg_expr (valist, type, pre_p, post_p);
  }


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