* trans.c (call_to_gnu): Use build_call_list instead of build3 to
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Feb 2007 23:40:52 +0000 (23:40 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 16 Feb 2007 23:40:52 +0000 (23:40 +0000)
build the call expression.
(gnat_stabilize_reference_1): Handle tcc_vl_exp.
* utils.c (max_size) <tcc_exceptional>: Delete.
<tcc_vl_exp>: New case.
<tcc_expression>: Delete CALL_EXPR subcase.
(build_global_cdtor): Use build_call_nary instead of build3.
* utils2.c (build_call_1_expr): Likewise.
(build_call_2_expr): Likewise.
(build_call_0_expr): Likewise.
(build_call_alloc_dealloc): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122058 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/trans.c
gcc/ada/utils.c
gcc/ada/utils2.c

index cf92c83..493a41e 100644 (file)
@@ -1,3 +1,18 @@
+2007-02-16  Eric Botcazou  <ebotcazou@adacore.com>
+            Sandra Loosemore  <sandra@codesourcery.com>
+
+       * trans.c (call_to_gnu):  Use build_call_list instead of build3 to
+       build the call expression.
+       (gnat_stabilize_reference_1): Handle tcc_vl_exp.
+       * utils.c (max_size) <tcc_exceptional>: Delete.
+       <tcc_vl_exp>: New case.
+       <tcc_expression>: Delete CALL_EXPR subcase.
+       (build_global_cdtor): Use build_call_nary instead of build3.
+       * utils2.c (build_call_1_expr): Likewise.
+       (build_call_2_expr): Likewise.
+       (build_call_0_expr): Likewise.
+       (build_call_alloc_dealloc): Likewise.
+
 2007-02-07  Andreas Krebbel  <krebbel1@de.ibm.com>
 
        * raise-gcc.c (get_region_description_for, get_call_site_action_for,
index eee950b..6788012 100644 (file)
@@ -389,12 +389,12 @@ Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p)
      enclosing block, but we have no way of testing that right now.
 
      ??? We used to essentially set the TREE_ADDRESSABLE flag on the variable
-     here, but it can now be removed by the Tree aliasing machinery if the
-     address of the variable is never taken.  All we can do is to make the
-     variable volatile, which might incur the generation of temporaries just
-     to access the memory in some circumstances.  This can be avoided for
-     variables of non-constant size because they are automatically allocated
-     to memory.  There might be no way of allocating a proper temporary for
+     here, but it can now be removed by the Tree aliasing machinery if the
+     address of the variable is never taken.  All we can do is to make the
+     variable volatile, which might incur the generation of temporaries just
+     to access the memory in some circumstances.  This can be avoided for
+     variables of non-constant size because they are automatically allocated
+     to memory.  There might be no way of allocating a proper temporary for
      them in any case.  We only do this for SJLJ though.  */
   if (TREE_VALUE (gnu_except_ptr_stack)
       && TREE_CODE (gnu_result) == VAR_DECL
@@ -1992,9 +1992,9 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target)
       gnu_actual_list = tree_cons (NULL_TREE, gnu_actual, gnu_actual_list);
     }
 
-  gnu_subprog_call = build3 (CALL_EXPR, TREE_TYPE (gnu_subprog_type),
-                            gnu_subprog_addr, nreverse (gnu_actual_list),
-                            NULL_TREE);
+  gnu_subprog_call = build_call_list (TREE_TYPE (gnu_subprog_type),
+                                     gnu_subprog_addr,
+                                     nreverse (gnu_actual_list));
 
   /* If we return by passing a target, we emit the call and return the target
      as our result.  */
@@ -6132,6 +6132,7 @@ gnat_stabilize_reference_1 (tree e, bool force)
     case tcc_statement:
     case tcc_expression:
     case tcc_reference:
+    case tcc_vl_exp:
       /* If this is a COMPONENT_REF of a fat pointer, save the entire
         fat pointer.  This may be more efficient, but will also allow
         us to more easily find the match for the PLACEHOLDER_EXPR.  */
index 52bc663..6dc47de 100644 (file)
@@ -2335,12 +2335,18 @@ max_size (tree exp, bool max_p)
     case tcc_constant:
       return exp;
 
-    case tcc_exceptional:
-      if (code == TREE_LIST)
-       return tree_cons (TREE_PURPOSE (exp),
-                         max_size (TREE_VALUE (exp), max_p),
-                         TREE_CHAIN (exp)
-                         ? max_size (TREE_CHAIN (exp), max_p) : NULL_TREE);
+    case tcc_vl_exp:
+      if (code == CALL_EXPR)
+       {
+         tree *argarray;
+         int i, n = call_expr_nargs (exp);
+         gcc_assert (n > 0);
+
+         argarray = (tree *) alloca (n * sizeof (tree));
+         for (i = 0; i < n; i++)
+           argarray[i] = max_size (CALL_EXPR_ARG (exp, i), max_p);
+         return build_call_array (type, CALL_EXPR_FN (exp), n, argarray);
+       }
       break;
 
     case tcc_reference:
@@ -2428,9 +2434,6 @@ max_size (tree exp, bool max_p)
            return fold (build2 (max_p ? MAX_EXPR : MIN_EXPR, type,
                                 max_size (TREE_OPERAND (exp, 1), max_p),
                                 max_size (TREE_OPERAND (exp, 2), max_p)));
-         else if (code == CALL_EXPR && TREE_OPERAND (exp, 1))
-           return build3 (CALL_EXPR, type, TREE_OPERAND (exp, 0),
-                          max_size (TREE_OPERAND (exp, 1), max_p), NULL);
        }
 
       /* Other tree classes cannot happen.  */
@@ -3745,8 +3748,7 @@ build_global_cdtor (int method_type, tree *vec, int len)
     {
       tree fntype = TREE_TYPE (vec[i]);
       tree fnaddr = build1 (ADDR_EXPR, build_pointer_type (fntype), vec[i]);
-      tree fncall = build3 (CALL_EXPR, TREE_TYPE (fntype), fnaddr, NULL_TREE,
-                           NULL_TREE);
+      tree fncall = build_call_nary (TREE_TYPE (fntype), fnaddr, 0);
       append_to_statement_list (fncall, &body);
     }
 
index e987fa9..31b0c6d 100644 (file)
@@ -1394,13 +1394,10 @@ build_return_expr (tree result_decl, tree ret_val)
 tree
 build_call_1_expr (tree fundecl, tree arg)
 {
-  tree call = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fundecl)),
-                     build_unary_op (ADDR_EXPR, NULL_TREE, fundecl),
-                     chainon (NULL_TREE, build_tree_list (NULL_TREE, arg)),
-                     NULL_TREE);
-
+  tree call = build_call_nary (TREE_TYPE (TREE_TYPE (fundecl)),
+                              build_unary_op (ADDR_EXPR, NULL_TREE, fundecl),
+                              1, arg);
   TREE_SIDE_EFFECTS (call) = 1;
-
   return call;
 }
 
@@ -1410,15 +1407,10 @@ build_call_1_expr (tree fundecl, tree arg)
 tree
 build_call_2_expr (tree fundecl, tree arg1, tree arg2)
 {
-  tree call = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fundecl)),
-                     build_unary_op (ADDR_EXPR, NULL_TREE, fundecl),
-                     chainon (chainon (NULL_TREE,
-                                       build_tree_list (NULL_TREE, arg1)),
-                              build_tree_list (NULL_TREE, arg2)),
-                    NULL_TREE);
-
+  tree call = build_call_nary (TREE_TYPE (TREE_TYPE (fundecl)),
+                              build_unary_op (ADDR_EXPR, NULL_TREE, fundecl),
+                              2, arg1, arg2);
   TREE_SIDE_EFFECTS (call) = 1;
-
   return call;
 }
 
@@ -1427,13 +1419,11 @@ build_call_2_expr (tree fundecl, tree arg1, tree arg2)
 tree
 build_call_0_expr (tree fundecl)
 {
-  tree call = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (fundecl)),
-                     build_unary_op (ADDR_EXPR, NULL_TREE, fundecl),
-                     NULL_TREE, NULL_TREE);
-
-  /* We rely on build3 to compute TREE_SIDE_EFFECTS.  This makes it possible
-     to propagate the DECL_IS_PURE flag on parameterless functions.  */
-
+  /* We rely on build_call_nary to compute TREE_SIDE_EFFECTS.  This makes
+     it possible to propagate DECL_IS_PURE on parameterless functions.  */
+  tree call = build_call_nary (TREE_TYPE (TREE_TYPE (fundecl)),
+                              build_unary_op (ADDR_EXPR, NULL_TREE, fundecl),
+                              0);
   return call;
 }
 \f
@@ -1721,30 +1711,22 @@ build_call_alloc_dealloc (tree gnu_obj, tree gnu_size, unsigned align,
          tree gnu_proc_addr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_proc);
          tree gnu_pool = gnat_to_gnu (gnat_pool);
          tree gnu_pool_addr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_pool);
-         tree gnu_args = NULL_TREE;
          tree gnu_call;
 
+         gnu_size = convert (gnu_size_type, gnu_size);
+         gnu_align = convert (gnu_size_type, gnu_align);
+
          /* The first arg is always the address of the storage pool; next
             comes the address of the object, for a deallocator, then the
             size and alignment.  */
-         gnu_args
-           = chainon (gnu_args, build_tree_list (NULL_TREE, gnu_pool_addr));
-
          if (gnu_obj)
-           gnu_args
-             = chainon (gnu_args, build_tree_list (NULL_TREE, gnu_obj));
-
-         gnu_args
-           = chainon (gnu_args,
-                      build_tree_list (NULL_TREE,
-                                       convert (gnu_size_type, gnu_size)));
-         gnu_args
-           = chainon (gnu_args,
-                      build_tree_list (NULL_TREE,
-                                       convert (gnu_size_type, gnu_align)));
-
-         gnu_call = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (gnu_proc)),
-                            gnu_proc_addr, gnu_args, NULL_TREE);
+           gnu_call = build_call_nary (TREE_TYPE (TREE_TYPE (gnu_proc)),
+                                       gnu_proc_addr, 4, gnu_pool_addr,
+                                       gnu_obj, gnu_size, gnu_align);
+         else
+           gnu_call = build_call_nary (TREE_TYPE (TREE_TYPE (gnu_proc)),
+                                       gnu_proc_addr, 3, gnu_pool_addr,
+                                       gnu_size, gnu_align);
          TREE_SIDE_EFFECTS (gnu_call) = 1;
          return gnu_call;
        }
@@ -1758,22 +1740,18 @@ build_call_alloc_dealloc (tree gnu_obj, tree gnu_size, unsigned align,
          tree gnu_size_type = gnat_to_gnu_type (gnat_size_type);
          tree gnu_proc = gnat_to_gnu (gnat_proc);
          tree gnu_proc_addr = build_unary_op (ADDR_EXPR, NULL_TREE, gnu_proc);
-         tree gnu_args = NULL_TREE;
          tree gnu_call;
 
+         gnu_size = convert (gnu_size_type, gnu_size);
+
          /* The first arg is the address of the object, for a
             deallocator, then the size */
          if (gnu_obj)
-           gnu_args
-             = chainon (gnu_args, build_tree_list (NULL_TREE, gnu_obj));
-
-         gnu_args
-           = chainon (gnu_args,
-                      build_tree_list (NULL_TREE,
-                                       convert (gnu_size_type, gnu_size)));
-
-         gnu_call = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (gnu_proc)),
-                            gnu_proc_addr, gnu_args, NULL_TREE);
+           gnu_call = build_call_nary (TREE_TYPE (TREE_TYPE (gnu_proc)),
+                                       gnu_proc_addr, 2, gnu_obj, gnu_size);
+         else
+           gnu_call = build_call_nary (TREE_TYPE (TREE_TYPE (gnu_proc)),
+                                       gnu_proc_addr, 1, gnu_size);
          TREE_SIDE_EFFECTS (gnu_call) = 1;
          return gnu_call;
        }