* hooks.h (hook_tree_tree_tree_bool_null): Rename to...
authorfroydnj <froydnj@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 May 2010 16:23:27 +0000 (16:23 +0000)
committerfroydnj <froydnj@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 May 2010 16:23:27 +0000 (16:23 +0000)
(hook_tree_tree_int_treep_bool_null): ...this.  Update signature.
* hooks.c: Likewise.
* target-def.h (TARGET_FOLD_BUILTIN): Define to
hook_tree_tree_int_treep_bool_null.
* target.h: (struct gcc_target): Update signature of fold_builtin
field.
* doc/tm.texi (TARGET_FOLD_BUILTIN): Update description and signature.
* builtins.c (fold_call_expr): Pass call_expr_nargs and CALL_EXPR_ARGP
instead of the call expression.
(fold_builtin_call_array): Pass n and argarray directly.
(fold_call_stmt): Pass nargs and gimple_call_arg_ptr instead of
consing a list.
* config/alpha/alpha.c (alpha_fold_builtin): Update signature.  Lift
MAX_ARGS check out of the loop.  Delete declaration of `arity', declare
`i' and use it in place of `arity'.
* config/sparc/sparc.c (sparc_fold_builtin): Update signature.
Dereference `args' directly.
* config/xtensa/xtensa (xtensa_fold_builtin): Likewise.

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

gcc/ChangeLog
gcc/builtins.c
gcc/config/alpha/alpha.c
gcc/config/sparc/sparc.c
gcc/config/xtensa/xtensa.c
gcc/doc/tm.texi
gcc/hooks.c
gcc/hooks.h
gcc/target-def.h
gcc/target.h

index 4167712..d9a89d7 100644 (file)
@@ -1,3 +1,25 @@
+2010-05-19  Nathan Froyd  <froydnj@codesourcery.com>
+
+       * hooks.h (hook_tree_tree_tree_bool_null): Rename to...
+       (hook_tree_tree_int_treep_bool_null): ...this.  Update signature.
+       * hooks.c: Likewise.
+       * target-def.h (TARGET_FOLD_BUILTIN): Define to
+       hook_tree_tree_int_treep_bool_null.
+       * target.h: (struct gcc_target): Update signature of fold_builtin
+       field.
+       * doc/tm.texi (TARGET_FOLD_BUILTIN): Update description and signature.
+       * builtins.c (fold_call_expr): Pass call_expr_nargs and CALL_EXPR_ARGP
+       instead of the call expression.
+       (fold_builtin_call_array): Pass n and argarray directly.
+       (fold_call_stmt): Pass nargs and gimple_call_arg_ptr instead of
+       consing a list.
+       * config/alpha/alpha.c (alpha_fold_builtin): Update signature.  Lift
+       MAX_ARGS check out of the loop.  Delete declaration of `arity', declare
+       `i' and use it in place of `arity'.
+       * config/sparc/sparc.c (sparc_fold_builtin): Update signature.
+       Dereference `args' directly.
+       * config/xtensa/xtensa (xtensa_fold_builtin): Likewise.
+
 2010-05-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * doc/sourcebuild.texi (Effective-Target Keywords): Document
index 8541b82..6ad95ad 100644 (file)
@@ -10702,7 +10702,8 @@ fold_call_expr (location_t loc, tree exp, bool ignore)
        return NULL_TREE;
 
       if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
-        return targetm.fold_builtin (fndecl, exp, ignore);
+        return targetm.fold_builtin (fndecl, call_expr_nargs (exp),
+                                    CALL_EXPR_ARGP (exp), ignore);
       else
        {
          if (nargs <= MAX_ARGS_TO_FOLD_BUILTIN)
@@ -10766,7 +10767,6 @@ fold_builtin_call_array (location_t loc, tree type,
                         tree *argarray)
 {
   tree ret = NULL_TREE;
-  int i;
    tree exp;
 
   if (TREE_CODE (fn) == ADDR_EXPR)
@@ -10790,12 +10790,10 @@ fold_builtin_call_array (location_t loc, tree type,
          return build_call_array_loc (loc, type, fn, n, argarray);
         if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
           {
-            tree arglist = NULL_TREE;
-           for (i = n - 1; i >= 0; i--)
-             arglist = tree_cons (NULL_TREE, argarray[i], arglist);
-            ret = targetm.fold_builtin (fndecl, arglist, false);
-            if (ret)
-              return ret;
+           ret = targetm.fold_builtin (fndecl, n, argarray, false);
+           if (ret)
+             return ret;
+
            return build_call_array_loc (loc, type, fn, n, argarray);
           }
         else if (n <= MAX_ARGS_TO_FOLD_BUILTIN)
@@ -13698,14 +13696,10 @@ fold_call_stmt (gimple stmt, bool ignore)
 
       if (avoid_folding_inline_builtin (fndecl))
        return NULL_TREE;
-      /* FIXME: Don't use a list in this interface.  */
       if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD)
         {
-          tree arglist = NULL_TREE;
-          int i;
-          for (i = nargs - 1; i >= 0; i--)
-            arglist = tree_cons (NULL_TREE, gimple_call_arg (stmt, i), arglist);
-         return targetm.fold_builtin (fndecl, arglist, ignore);
+         return targetm.fold_builtin (fndecl, nargs,
+                                      gimple_call_arg_ptr (stmt, 0), ignore);
         }
       else
        {
index 7643267..2cc173f 100644 (file)
@@ -7138,26 +7138,27 @@ alpha_fold_builtin_ctpop (unsigned HOST_WIDE_INT opint[], long op_const)
 /* Fold one of our builtin functions.  */
 
 static tree
-alpha_fold_builtin (tree fndecl, tree call, bool ignore ATTRIBUTE_UNUSED)
+alpha_fold_builtin (tree fndecl, int n_args, tree *op,
+                   bool ignore ATTRIBUTE_UNUSED)
 {
-  tree *op = CALL_EXPR_ARGP (call);
   unsigned HOST_WIDE_INT opint[MAX_ARGS];
   long op_const = 0;
-  int arity;
+  int i;
 
-  for (i = 0; i < call_expr_nargs (call); i++)
+  if (n_args >= MAX_ARGS)
+    return NULL;
+
+  for (i = 0; i < n_args; i++)
     {
-      tree arg = CALL_EXPR_ARG (call, i);
+      tree arg = op[i];
       if (arg == error_mark_node)
        return NULL;
-      if (arity >= MAX_ARGS)
-       return NULL;
 
-      opint[arity] = 0;
+      opint[i] = 0;
       if (TREE_CODE (arg) == INTEGER_CST)
        {
-          op_const |= 1L << arity;
-         opint[arity] = int_cst_value (arg);
+          op_const |= 1L << i;
+         opint[i] = int_cst_value (arg);
        }
     }
 
index 8564312..9f9e20b 100644 (file)
@@ -386,7 +386,7 @@ static void sparc_init_libfuncs (void);
 static void sparc_init_builtins (void);
 static void sparc_vis_init_builtins (void);
 static rtx sparc_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
-static tree sparc_fold_builtin (tree, tree, bool);
+static tree sparc_fold_builtin (tree, int, tree *, bool);
 static int sparc_vis_mul8x16 (int, int);
 static tree sparc_handle_vis_mul8x16 (int, tree, tree, tree);
 static void sparc_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
@@ -8372,7 +8372,8 @@ sparc_handle_vis_mul8x16 (int fncode, tree inner_type, tree elts0, tree elts1)
    function could not be folded.  */
 
 static tree
-sparc_fold_builtin (tree fndecl, tree call, bool ignore)
+sparc_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED,
+                   tree *args, bool ignore)
 {
   tree arg0, arg1, arg2;
   tree rtype = TREE_TYPE (TREE_TYPE (fndecl));
@@ -8386,7 +8387,7 @@ sparc_fold_builtin (tree fndecl, tree call, bool ignore)
   switch (icode)
     {
     case CODE_FOR_fexpand_vis:
-      arg0 = CALL_EXPR_ARG (call, 0);
+      arg0 = args[0];
       STRIP_NOPS (arg0);
 
       if (TREE_CODE (arg0) == VECTOR_CST)
@@ -8409,8 +8410,8 @@ sparc_fold_builtin (tree fndecl, tree call, bool ignore)
     case CODE_FOR_fmul8x16_vis:
     case CODE_FOR_fmul8x16au_vis:
     case CODE_FOR_fmul8x16al_vis:
-      arg0 = CALL_EXPR_ARG (call, 0);
-      arg1 = CALL_EXPR_ARG (call, 1);
+      arg0 = args[0];
+      arg1 = args[1];
       STRIP_NOPS (arg0);
       STRIP_NOPS (arg1);
 
@@ -8427,8 +8428,8 @@ sparc_fold_builtin (tree fndecl, tree call, bool ignore)
       break;
 
     case CODE_FOR_fpmerge_vis:
-      arg0 = CALL_EXPR_ARG (call, 0);
-      arg1 = CALL_EXPR_ARG (call, 1);
+      arg0 = args[0];
+      arg1 = args[1];
       STRIP_NOPS (arg0);
       STRIP_NOPS (arg1);
 
@@ -8450,9 +8451,9 @@ sparc_fold_builtin (tree fndecl, tree call, bool ignore)
       break;
 
     case CODE_FOR_pdist_vis:
-      arg0 = CALL_EXPR_ARG (call, 0);
-      arg1 = CALL_EXPR_ARG (call, 1);
-      arg2 = CALL_EXPR_ARG (call, 2);
+      arg0 = args[0];
+      arg1 = args[1];
+      arg2 = args[2];
       STRIP_NOPS (arg0);
       STRIP_NOPS (arg1);
       STRIP_NOPS (arg2);
index fac7e51..97b941d 100644 (file)
@@ -142,7 +142,7 @@ static tree xtensa_gimplify_va_arg_expr (tree, tree, gimple_seq *,
                                         gimple_seq *);
 static rtx xtensa_function_value (const_tree, const_tree, bool);
 static void xtensa_init_builtins (void);
-static tree xtensa_fold_builtin (tree, tree, bool);
+static tree xtensa_fold_builtin (tree, int, tree *, bool);
 static rtx xtensa_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
 static void xtensa_va_start (tree, rtx);
 static bool xtensa_frame_pointer_required (void);
@@ -3000,7 +3000,8 @@ xtensa_init_builtins (void)
 
 
 static tree
-xtensa_fold_builtin (tree fndecl, tree call, bool ignore ATTRIBUTE_UNUSED)
+xtensa_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *args,
+                    bool ignore ATTRIBUTE_UNUSED)
 {
   unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
   tree arg0, arg1;
@@ -3008,8 +3009,8 @@ xtensa_fold_builtin (tree fndecl, tree call, bool ignore ATTRIBUTE_UNUSED)
   switch (fcode)
     {
     case XTENSA_BUILTIN_UMULSIDI3:
-      arg0 = CALL_EXPR_ARG (call, 0);
-      arg1 = CALL_EXPR_ARG (call, 1);
+      arg0 = args[0];
+      arg1 = args[1];
       if ((TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST)
          || TARGET_MUL32_HIGH)
        return fold_build2 (MULT_EXPR, unsigned_intDI_type_node,
index 8f9bbe7..80e28a3 100644 (file)
@@ -10784,14 +10784,14 @@ another @code{CALL_EXPR}.
 @var{arglist} really has type @samp{VEC(tree,gc)*}
 @end deftypefn
 
-@deftypefn {Target Hook} tree TARGET_FOLD_BUILTIN (tree @var{fndecl}, tree @var{call}, bool @var{ignore})
+@deftypefn {Target Hook} tree TARGET_FOLD_BUILTIN (tree @var{fndecl}, int @var{n_args}, tree *@var{argp}, bool @var{ignore})
 
 Fold a call to a machine specific built-in function that was set up by
 @samp{TARGET_INIT_BUILTINS}.  @var{fndecl} is the declaration of the
-built-in function.  @var{call} is the @code{CALL_EXPR} representing
-the call.  The result is another tree containing a
-simplified expression for the call's result.  If @var{ignore} is true
-the value will be ignored.
+built-in function.  @var{n_args} is the number of arguments passed to
+the function; the arguments themselves are pointed to by @var{argp}.
+The result is another tree containing a simplified expression for the
+call's result.  If @var{ignore} is true the value will be ignored.
 @end deftypefn
 
 @deftypefn {Target Hook} {const char *} TARGET_INVALID_WITHIN_DOLOOP (const_rtx @var{insn})
index aac4448..97e1064 100644 (file)
@@ -299,9 +299,10 @@ hook_constcharptr_const_tree_null (const_tree t ATTRIBUTE_UNUSED)
 }
 
 tree
-hook_tree_tree_tree_bool_null (tree t0 ATTRIBUTE_UNUSED,
-                              tree t1 ATTRIBUTE_UNUSED,
-                              bool ignore ATTRIBUTE_UNUSED)
+hook_tree_tree_int_treep_bool_null (tree t0 ATTRIBUTE_UNUSED,
+                                   int i ATTRIBUTE_UNUSED,
+                                   tree *p ATTRIBUTE_UNUSED,
+                                   bool ignore ATTRIBUTE_UNUSED)
 {
   return NULL;
 }
index 5fd8296..5028062 100644 (file)
@@ -71,7 +71,7 @@ extern tree hook_tree_const_tree_null (const_tree);
 extern tree hook_tree_tree_tree_null (tree, tree);
 extern tree hook_tree_tree_tree_tree_null (tree, tree, tree);
 extern tree hook_tree_tree_tree_tree_3rd_identity (tree, tree, tree);
-extern tree hook_tree_tree_tree_bool_null (tree, tree, bool);
+extern tree hook_tree_tree_int_treep_bool_null (tree, int, tree *, bool);
 
 extern unsigned hook_uint_uint_constcharptrptr_0 (unsigned, const char **);
 
index 3ead370..09da722 100644 (file)
 #define TARGET_INIT_BUILTINS hook_void_void
 #define TARGET_EXPAND_BUILTIN default_expand_builtin
 #define TARGET_RESOLVE_OVERLOADED_BUILTIN NULL
-#define TARGET_FOLD_BUILTIN hook_tree_tree_tree_bool_null
+#define TARGET_FOLD_BUILTIN hook_tree_tree_int_treep_bool_null
 #define TARGET_BUILTIN_DECL NULL
 
 /* In tree-ssa-math-opts.c  */
index 29ec84f..7447900 100644 (file)
@@ -616,7 +616,7 @@ struct gcc_target
                                      tree decl, void *params);
 
   /* Fold a target-specific builtin.  */
-  tree (* fold_builtin) (tree fndecl, tree arglist, bool ignore);
+  tree (* fold_builtin) (tree fndecl, int nargs, tree *argp, bool ignore);
 
   /* Returns a code for a target-specific builtin that implements
      reciprocal of the function, or NULL_TREE if not available.  */