Hi, during testing of the new in-review C-SKY port, we discovered some FAILs 
due to
the default va_args gimplifying (targhooks.c:std_gimplify_va_arg_expr) not 
properly
having the logic to handle the TARGET_SPLIT_COMPLEX_ARG hook.

It appears that all other targets that happen to use TARGET_SPLIT_COMPLEX_ARG 
also
defines TARGET_GIMPLIFY_VA_ARG_EXPR, so this went undiscovered.
The C-SKY port happens to only have TARGET_SPLIT_COMPLEX_ARG defined.

This patch completes this handling in std_gimplify_va_arg_expr(), though at the
moment it's only really exercised by the C-SKY port, which we tested to fix 
several
_Complex va_args related FAILs and without regressions.
(the patch fragment is actually adapted from the xtensa port, FWIW)

Is this okay for trunk?

Thanks,
Chung-Lin

2018-08-02  Chung-Lin Tang  <clt...@codesourcery.com>

        * targhooks.c (std_gimplify_va_arg_expr): Properly handle case of when
        TARGET_SPLIT_COMPLEX_ARG is defined.
Index: targhooks.c
===================================================================
--- targhooks.c (revision 263244)
+++ targhooks.c (working copy)
@@ -2154,6 +2154,23 @@ std_gimplify_va_arg_expr (tree valist, tree type,
   if (indirect)
     type = build_pointer_type (type);
 
+  if (targetm.calls.split_complex_arg
+      && TREE_CODE (type) == COMPLEX_TYPE
+      && targetm.calls.split_complex_arg (type))
+    {
+      tree real_part, imag_part;
+
+      real_part = std_gimplify_va_arg_expr (valist,
+                                           TREE_TYPE (type), pre_p, NULL);
+      real_part = get_initialized_tmp_var (real_part, pre_p, NULL);
+
+      imag_part = std_gimplify_va_arg_expr (unshare_expr (valist),
+                                           TREE_TYPE (type), pre_p, NULL);
+      imag_part = get_initialized_tmp_var (imag_part, pre_p, NULL);
+
+      return build2 (COMPLEX_EXPR, type, real_part, imag_part);
+   }
+
   align = PARM_BOUNDARY / BITS_PER_UNIT;
   boundary = targetm.calls.function_arg_boundary (TYPE_MODE (type), type);
 

Reply via email to