From 9b2b72791eb7506db1e6cdd17f1201dcd9e96e64 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Mon, 2 Jun 2014 20:13:44 +0000
Subject: [PATCH] expr.h: Remove prototypes of functions defined in builtins.c.

	* expr.h: Remove prototypes of functions defined in builtins.c.
	* tree.h: (build_call_expr_*, build_string_literal): Add prototypes.
	Remove prototypes of functions defined in builtins.c.
	* builtins.h: Update prototype list to include all exported functions.
	* builtins.c: (default_libc_has_function, gnu_libc_has_function,
	no_c99_libc_has_function): Move to targhooks.c
	(build_string_literal, build_call_expr_loc_array,
	build_call_expr_loc_vec, build_call_expr_loc, build_call_expr): Move
	to tree.c.
	(expand_builtin_object_size, fold_builtin_object_size): Make static.
	* targhooks.c (default_libc_has_function, gnu_libc_has_function,
	no_c99_libc_has_function): Relocate from builtins.c.
	* tree.c: Include builtins.h.
	(build_call_expr_loc_array, build_call_expr_loc_vec,
	build_call_expr_loc, build_call_expr, build_string_literal): Relocate
	from builtins.c.
	* fold-const.h (fold_fma): Move prototype to builtins.h.
	* realmpfr.h (do_mpc_arg2): Move prototype to builtins.h.

	* fortran/trans.c (trans_runtime_error_vararg): Call
	fold_build_call_array_loc instead of fold_builtin_call_array.

	* asan.c: Include builtins.h.
	* cfgexpand.c: Likewise.
	* convert.c: Likewise.
	* emit-rtl.c: Likewise.
	* except.c: Likewise.
	* expr.c: Likewise.
	* fold-const.c: Likewise.
	* gimple-fold.c: Likewise.
	* gimple-ssa-strength-reduction.c: Likewise.
	* gimplify.c: Likewise.
	* ipa-inline.c: Likewise.
	* ipa-prop.c: Likewise.
	* lto-streamer-out.c: Likewise.
	* stmt.c: Likewise.
	* tree-inline.c: Likewise.
	* tree-object-size.c: Likewise.
	* tree-sra.c: Likewise.
	* tree-ssa-ccp.c: Likewise.
	* tree-ssa-forwprop.c: Likewise.
	* tree-ssa-loop-ivcanon.c: Likewise.
	* tree-ssa-loop-ivopts.c: Likewise.
	* tree-ssa-math-opts.c: Likewise.
	* tree-ssa-reassoc.c: Likewise.
	* tree-ssa-threadedge.c: Likewise.
	* tree-streamer-in.c: Likewise.
	* tree-vect-data-refs.c: Likewise.
	* tree-vect-patterns.c: Likewise.
	* tree-vect-stmts.c: Likewise.

	c
	* c-decl.c: Include builtins.h.
	* c-parser.c: Likewise.

	cp
	* decl.c: Include builtins.h.
	* semantics.c: Likewise.

	go
	* go-gcc.cc: Include builtins.h.

	lto
	* lto-symtab.c: Include builtins.h.

	config
	* aarch64/aarch64.c: Include builtins.h.
	* alpha/alpha.c: Likewise.
	* arc/arc.c: Likewise.
	* arm/arm.c: Likewise.
	* avr/avr.c: Likewise.
	* bfin/bfin.c: Likewise.
	* c6x/c6x.c: Likewise.
	* cr16/cr16.c: Likewise.
	* cris/cris.c: Likewise.
	* epiphany/epiphany.c: Likewise.
	* fr30/fr30.c: Likewise.
	* frv/frv.c: Likewise.
	* h8300/h8300.c: Likewise.
	* i386/i386.c: Likewise.
	* i386/winnt.c: Likewise.
	* ia64/ia64.c: Likewise.
	* iq2000/iq2000.c: Likewise.
	* lm32/lm32.c: Likewise.
	* m32c/m32c.c: Likewise.
	* m32r/m32r.c: Likewise.
	* m68k/m68k.c: Likewise.
	* mcore/mcore.c: Likewise.
	* mep/mep.c: Likewise.
	* microblaze/microblaze.c: Likewise.
	* mips/mips.c: Likewise.
	* mmix/mmix.c: Likewise.
	* mn10300/mn10300.c: Likewise.
	* moxie/moxie.c: Likewise.
	* msp430/msp430.c: Likewise.
	* nds32/nds32.c: Likewise.
	* pa/pa.c: Likewise.
	* pdp11/pdp11.c: Likewise.
	* picochip/picochip.c: Likewise.
	* rl78/rl78.c: Likewise.
	* rs6000/rs6000.c: Likewise.
	* rx/rx.c: Likewise.
	* s390/s390.c: Likewise.
	* score/score.c: Likewise.
	* sh/sh.c: Likewise.
	* sparc/sparc.c: Likewise.
	* spu/spu.c: Likewise.
	* stormy16/stormy16.c: Likewise.
	* tilegx/tilegx.c: Likewise.
	* tilepro/tilepro.c: Likewise.
	* v850/v850.c: Likewise.
	* vax/vax.c: Likewise.
	* xtensa/xtensa.c: Likewise.

From-SVN: r211145
---
 gcc/ChangeLog                       |  96 ++++++++++++++++++++++++
 gcc/asan.c                          |   1 +
 gcc/builtins.c                      | 112 +---------------------------
 gcc/builtins.h                      |  50 +++++++++++++
 gcc/c/ChangeLog                     |   5 ++
 gcc/c/c-decl.c                      |   1 +
 gcc/c/c-parser.c                    |   1 +
 gcc/cfgexpand.c                     |   1 +
 gcc/config/aarch64/aarch64.c        |   1 +
 gcc/config/alpha/alpha.c            |   1 +
 gcc/config/arc/arc.c                |   1 +
 gcc/config/arm/arm.c                |   1 +
 gcc/config/avr/avr.c                |   1 +
 gcc/config/bfin/bfin.c              |   1 +
 gcc/config/c6x/c6x.c                |   1 +
 gcc/config/cr16/cr16.c              |   1 +
 gcc/config/cris/cris.c              |   1 +
 gcc/config/epiphany/epiphany.c      |   1 +
 gcc/config/fr30/fr30.c              |   1 +
 gcc/config/frv/frv.c                |   1 +
 gcc/config/h8300/h8300.c            |   1 +
 gcc/config/i386/i386.c              |   1 +
 gcc/config/i386/winnt.c             |   1 +
 gcc/config/ia64/ia64.c              |   1 +
 gcc/config/iq2000/iq2000.c          |   1 +
 gcc/config/lm32/lm32.c              |   1 +
 gcc/config/m32c/m32c.c              |   1 +
 gcc/config/m32r/m32r.c              |   1 +
 gcc/config/m68k/m68k.c              |   1 +
 gcc/config/mcore/mcore.c            |   1 +
 gcc/config/mep/mep.c                |   1 +
 gcc/config/microblaze/microblaze.c  |   1 +
 gcc/config/mips/mips.c              |   1 +
 gcc/config/mmix/mmix.c              |   1 +
 gcc/config/mn10300/mn10300.c        |   1 +
 gcc/config/moxie/moxie.c            |   1 +
 gcc/config/msp430/msp430.c          |   1 +
 gcc/config/nds32/nds32.c            |   1 +
 gcc/config/pa/pa.c                  |   1 +
 gcc/config/pdp11/pdp11.c            |   1 +
 gcc/config/picochip/picochip.c      |   1 +
 gcc/config/rl78/rl78.c              |   1 +
 gcc/config/rs6000/rs6000.c          |   1 +
 gcc/config/rx/rx.c                  |   1 +
 gcc/config/s390/s390.c              |   1 +
 gcc/config/score/score.c            |   1 +
 gcc/config/sh/sh.c                  |   1 +
 gcc/config/sparc/sparc.c            |   1 +
 gcc/config/spu/spu.c                |   1 +
 gcc/config/stormy16/stormy16.c      |   1 +
 gcc/config/tilegx/tilegx.c          |   1 +
 gcc/config/tilepro/tilepro.c        |   1 +
 gcc/config/v850/v850.c              |   1 +
 gcc/config/vax/vax.c                |   1 +
 gcc/config/xtensa/xtensa.c          |   1 +
 gcc/convert.c                       |   1 +
 gcc/cp/ChangeLog                    |   5 ++
 gcc/cp/decl.c                       |   1 +
 gcc/cp/semantics.c                  |   1 +
 gcc/emit-rtl.c                      |   1 +
 gcc/except.c                        |   1 +
 gcc/expr.c                          |   1 +
 gcc/expr.h                          |  14 ----
 gcc/fold-const.c                    |   1 +
 gcc/fold-const.h                    |   1 -
 gcc/fortran/ChangeLog               |   5 ++
 gcc/fortran/trans.c                 |   6 +-
 gcc/gimple-fold.c                   |   1 +
 gcc/gimple-ssa-strength-reduction.c |   1 +
 gcc/gimplify.c                      |   1 +
 gcc/go/ChangeLog                    |   4 +
 gcc/go/go-gcc.cc                    |   1 +
 gcc/ipa-inline.c                    |   1 +
 gcc/ipa-prop.c                      |   1 +
 gcc/lto-streamer-out.c              |   1 +
 gcc/lto/ChangeLog                   |   4 +
 gcc/lto/lto-symtab.c                |   1 +
 gcc/realmpfr.h                      |   3 -
 gcc/stmt.c                          |   1 +
 gcc/targhooks.c                     |  25 +++++++
 gcc/tree-inline.c                   |   1 +
 gcc/tree-object-size.c              |   1 +
 gcc/tree-sra.c                      |   1 +
 gcc/tree-ssa-ccp.c                  |   1 +
 gcc/tree-ssa-forwprop.c             |   1 +
 gcc/tree-ssa-loop-ivcanon.c         |   1 +
 gcc/tree-ssa-loop-ivopts.c          |   1 +
 gcc/tree-ssa-math-opts.c            |   1 +
 gcc/tree-ssa-reassoc.c              |   1 +
 gcc/tree-ssa-threadedge.c           |   1 +
 gcc/tree-streamer-in.c              |   1 +
 gcc/tree-vect-data-refs.c           |   1 +
 gcc/tree-vect-patterns.c            |   1 +
 gcc/tree-vect-stmts.c               |   1 +
 gcc/tree.c                          |  86 +++++++++++++++++++++
 gcc/tree.h                          |  47 ++----------
 96 files changed, 371 insertions(+), 173 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index acefcc0b400f..1f9f102c53e7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,99 @@
+2014-06-02  Andrew MacLeod  <amacleod@redhat.com>
+
+	* expr.h: Remove prototypes of functions defined in builtins.c.
+	* tree.h: (build_call_expr_*, build_string_literal): Add prototypes.
+	Remove prototypes of functions defined in builtins.c.
+	* builtins.h: Update prototype list to include all exported functions.
+	* builtins.c: (default_libc_has_function, gnu_libc_has_function,
+	no_c99_libc_has_function): Move to targhooks.c
+	(build_string_literal, build_call_expr_loc_array,
+	build_call_expr_loc_vec, build_call_expr_loc, build_call_expr): Move
+	to tree.c.
+	(expand_builtin_object_size, fold_builtin_object_size): Make static.
+	* targhooks.c (default_libc_has_function, gnu_libc_has_function,
+	no_c99_libc_has_function): Relocate from builtins.c.
+	* tree.c: Include builtins.h.
+	(build_call_expr_loc_array, build_call_expr_loc_vec,
+	build_call_expr_loc, build_call_expr, build_string_literal): Relocate
+	from builtins.c.
+	* fold-const.h (fold_fma): Move prototype to builtins.h.
+	* realmpfr.h (do_mpc_arg2): Move prototype to builtins.h.
+	* asan.c: Include builtins.h.
+	* cfgexpand.c: Likewise.
+	* convert.c: Likewise.
+	* emit-rtl.c: Likewise.
+	* except.c: Likewise.
+	* expr.c: Likewise.
+	* fold-const.c: Likewise.
+	* gimple-fold.c: Likewise.
+	* gimple-ssa-strength-reduction.c: Likewise.
+	* gimplify.c: Likewise.
+	* ipa-inline.c: Likewise.
+	* ipa-prop.c: Likewise.
+	* lto-streamer-out.c: Likewise.
+	* stmt.c: Likewise.
+	* tree-inline.c: Likewise.
+	* tree-object-size.c: Likewise.
+	* tree-sra.c: Likewise.
+	* tree-ssa-ccp.c: Likewise.
+	* tree-ssa-forwprop.c: Likewise.
+	* tree-ssa-loop-ivcanon.c: Likewise.
+	* tree-ssa-loop-ivopts.c: Likewise.
+	* tree-ssa-math-opts.c: Likewise.
+	* tree-ssa-reassoc.c: Likewise.
+	* tree-ssa-threadedge.c: Likewise.
+	* tree-streamer-in.c: Likewise.
+	* tree-vect-data-refs.c: Likewise.
+	* tree-vect-patterns.c: Likewise.
+	* tree-vect-stmts.c: Likewise.
+	* config/aarch64/aarch64.c: Likewise.
+	* config/alpha/alpha.c: Likewise.
+	* config/arc/arc.c: Likewise.
+	* config/arm/arm.c: Likewise.
+	* config/avr/avr.c: Likewise.
+	* config/bfin/bfin.c: Likewise.
+	* config/c6x/c6x.c: Likewise.
+	* config/cr16/cr16.c: Likewise.
+	* config/cris/cris.c: Likewise.
+	* config/epiphany/epiphany.c: Likewise.
+	* config/fr30/fr30.c: Likewise.
+	* config/frv/frv.c: Likewise.
+	* config/h8300/h8300.c: Likewise.
+	* config/i386/i386.c: Likewise.
+	* config/i386/winnt.c: Likewise.
+	* config/ia64/ia64.c: Likewise.
+	* config/iq2000/iq2000.c: Likewise.
+	* config/lm32/lm32.c: Likewise.
+	* config/m32c/m32c.c: Likewise.
+	* config/m32r/m32r.c: Likewise.
+	* config/m68k/m68k.c: Likewise.
+	* config/mcore/mcore.c: Likewise.
+	* config/mep/mep.c: Likewise.
+	* config/microblaze/microblaze.c: Likewise.
+	* config/mips/mips.c: Likewise.
+	* config/mmix/mmix.c: Likewise.
+	* config/mn10300/mn10300.c: Likewise.
+	* config/moxie/moxie.c: Likewise.
+	* config/msp430/msp430.c: Likewise.
+	* config/nds32/nds32.c: Likewise.
+	* config/pa/pa.c: Likewise.
+	* config/pdp11/pdp11.c: Likewise.
+	* config/picochip/picochip.c: Likewise.
+	* config/rl78/rl78.c: Likewise.
+	* config/rs6000/rs6000.c: Likewise.
+	* config/rx/rx.c: Likewise.
+	* config/s390/s390.c: Likewise.
+	* config/score/score.c: Likewise.
+	* config/sh/sh.c: Likewise.
+	* config/sparc/sparc.c: Likewise.
+	* config/spu/spu.c: Likewise.
+	* config/stormy16/stormy16.c: Likewise.
+	* config/tilegx/tilegx.c: Likewise.
+	* config/tilepro/tilepro.c: Likewise.
+	* config/v850/v850.c: Likewise.
+	* config/vax/vax.c: Likewise.
+	* config/xtensa/xtensa.c: Likewise.
+
 2014-06-02  Jeff Law  <law@redhat.com>
 
 	PR rtl-optimization/61094
diff --git a/gcc/asan.c b/gcc/asan.c
index 339765523a8f..5021338b8550 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ubsan.h"
 #include "predict.h"
 #include "params.h"
+#include "builtins.h"
 
 /* AddressSanitizer finds out-of-bounds and use-after-free bugs
    with <2x slowdown on average.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 140d6ba1a5b6..2d3d867b0b2d 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -259,31 +259,6 @@ is_builtin_fn (tree decl)
   return TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl);
 }
 
-/* By default we assume that c99 functions are present at the runtime,
-   but sincos is not.  */
-bool
-default_libc_has_function (enum function_class fn_class)
-{
-  if (fn_class == function_c94
-      || fn_class == function_c99_misc
-      || fn_class == function_c99_math_complex)
-    return true;
-
-  return false;
-}
-
-bool
-gnu_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
-{
-  return true;
-}
-
-bool
-no_c99_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
-{
-  return false;
-}
-
 /* Return true if NODE should be considered for inline expansion regardless
    of the optimization level.  This means whenever a function is invoked with
    its "internal" name, which normally contains the prefix "__builtin".  */
@@ -4690,29 +4665,6 @@ expand_builtin_copysign (tree exp, rtx target, rtx subtarget)
   return expand_copysign (op0, op1, target);
 }
 
-/* Create a new constant string literal and return a char* pointer to it.
-   The STRING_CST value is the LEN characters at STR.  */
-tree
-build_string_literal (int len, const char *str)
-{
-  tree t, elem, index, type;
-
-  t = build_string (len, str);
-  elem = build_type_variant (char_type_node, 1, 0);
-  index = build_index_type (size_int (len - 1));
-  type = build_array_type (elem, index);
-  TREE_TYPE (t) = type;
-  TREE_CONSTANT (t) = 1;
-  TREE_READONLY (t) = 1;
-  TREE_STATIC (t) = 1;
-
-  type = build_pointer_type (elem);
-  t = build1 (ADDR_EXPR, type,
-	      build4 (ARRAY_REF, elem,
-		      t, integer_zero_node, NULL_TREE, NULL_TREE));
-  return t;
-}
-
 /* Expand a call to __builtin___clear_cache.  */
 
 static rtx
@@ -11159,66 +11111,6 @@ fold_call_expr (location_t loc, tree exp, bool ignore)
   return NULL_TREE;
 }
 
-/* Conveniently construct a function call expression.  FNDECL names the
-   function to be called and N arguments are passed in the array
-   ARGARRAY.  */
-
-tree
-build_call_expr_loc_array (location_t loc, tree fndecl, int n, tree *argarray)
-{
-  tree fntype = TREE_TYPE (fndecl);
-  tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
- 
-  return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, n, argarray);
-}
-
-/* Conveniently construct a function call expression.  FNDECL names the
-   function to be called and the arguments are passed in the vector
-   VEC.  */
-
-tree
-build_call_expr_loc_vec (location_t loc, tree fndecl, vec<tree, va_gc> *vec)
-{
-  return build_call_expr_loc_array (loc, fndecl, vec_safe_length (vec),
-				    vec_safe_address (vec));
-}
-
-
-/* Conveniently construct a function call expression.  FNDECL names the
-   function to be called, N is the number of arguments, and the "..."
-   parameters are the argument expressions.  */
-
-tree
-build_call_expr_loc (location_t loc, tree fndecl, int n, ...)
-{
-  va_list ap;
-  tree *argarray = XALLOCAVEC (tree, n);
-  int i;
-
-  va_start (ap, n);
-  for (i = 0; i < n; i++)
-    argarray[i] = va_arg (ap, tree);
-  va_end (ap);
-  return build_call_expr_loc_array (loc, fndecl, n, argarray);
-}
-
-/* Like build_call_expr_loc (UNKNOWN_LOCATION, ...).  Duplicated because
-   varargs macros aren't supported by all bootstrap compilers.  */
-
-tree
-build_call_expr (tree fndecl, int n, ...)
-{
-  va_list ap;
-  tree *argarray = XALLOCAVEC (tree, n);
-  int i;
-
-  va_start (ap, n);
-  for (i = 0; i < n; i++)
-    argarray[i] = va_arg (ap, tree);
-  va_end (ap);
-  return build_call_expr_loc_array (UNKNOWN_LOCATION, fndecl, n, argarray);
-}
-
 /* Construct a CALL_EXPR with type TYPE with FN as the function expression.
    N arguments are passed in the array ARGARRAY.  */
 
@@ -12281,7 +12173,7 @@ fold_builtin_snprintf (location_t loc, tree dest, tree destsize, tree fmt,
 
 /* Expand a call EXP to __builtin_object_size.  */
 
-rtx
+static rtx
 expand_builtin_object_size (tree exp)
 {
   tree ost;
@@ -12586,7 +12478,7 @@ maybe_emit_free_warning (tree exp)
 /* Fold a call to __builtin_object_size with arguments PTR and OST,
    if possible.  */
 
-tree
+static tree
 fold_builtin_object_size (tree ptr, tree ost)
 {
   unsigned HOST_WIDE_INT bytes;
diff --git a/gcc/builtins.h b/gcc/builtins.h
index 5eb930369d4b..8be990e8d8a5 100644
--- a/gcc/builtins.h
+++ b/gcc/builtins.h
@@ -20,6 +20,8 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_BUILTINS_H
 #define GCC_BUILTINS_H
 
+#include <mpc.h>
+
 /* Target-dependent globals.  */
 struct target_builtins {
   /* For each register that may be used for calling a function, this
@@ -44,6 +46,54 @@ extern struct target_builtins *this_target_builtins;
 #define this_target_builtins (&default_target_builtins)
 #endif
 
+/* Non-zero if __builtin_constant_p should be folded right away.  */
+extern bool force_folding_builtin_constant_p;
+
+extern bool is_builtin_fn (tree);
+extern bool get_object_alignment_1 (tree, unsigned int *,
+				    unsigned HOST_WIDE_INT *);
+extern unsigned int get_object_alignment (tree);
+extern bool get_pointer_alignment_1 (tree, unsigned int *,
+				     unsigned HOST_WIDE_INT *);
+extern unsigned int get_pointer_alignment (tree);
+extern tree c_strlen (tree, int);
+extern void expand_builtin_setjmp_setup (rtx, rtx);
+extern void expand_builtin_setjmp_receiver (rtx);
+extern tree mathfn_built_in (tree, enum built_in_function fn);
+extern rtx builtin_strncpy_read_str (void *, HOST_WIDE_INT, enum machine_mode);
+extern rtx builtin_memset_read_str (void *, HOST_WIDE_INT, enum machine_mode);
+extern rtx expand_builtin_saveregs (void);
+extern tree std_build_builtin_va_list (void);
+extern tree std_fn_abi_va_list (tree);
+extern tree std_canonical_va_list_type (tree);
+extern void std_expand_builtin_va_start (tree, rtx);
+extern void expand_builtin_trap (void);
+extern rtx expand_builtin (tree, rtx, rtx, enum machine_mode, int);
+extern enum built_in_function builtin_mathfn_code (const_tree);
+extern tree fold_builtin_expect (location_t, tree, tree, tree);
+extern tree fold_builtin_strcpy (location_t, tree, tree, tree, tree);
+extern tree fold_builtin_strncpy (location_t, tree, tree, tree, tree, tree);
+extern tree fold_fma (location_t, tree, tree, tree, tree);
+extern bool avoid_folding_inline_builtin (tree);
+extern tree fold_call_expr (location_t, tree, bool);
+extern tree fold_builtin_call_array (location_t, tree, tree, int, tree *);
 extern bool validate_gimple_arglist (const_gimple, ...);
+extern rtx default_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
+extern tree fold_builtin_strcat (location_t, tree, tree, tree);
+extern tree fold_builtin_fputs (location_t, tree, tree, bool, bool, tree);
+extern bool fold_builtin_next_arg (tree, bool);
+extern tree fold_builtin_memory_chk (location_t, tree, tree, tree, tree, tree,
+				     tree, bool, enum built_in_function);
+extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, tree,
+				     bool, enum built_in_function);
+extern tree fold_builtin_stxncpy_chk (location_t, tree, tree, tree, tree, tree,
+				      bool, enum built_in_function);
+extern tree gimple_fold_builtin_snprintf_chk (gimple, tree,
+					      enum built_in_function);
+extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
+extern tree fold_call_stmt (gimple, bool);
+extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
+extern bool is_simple_builtin (tree);
+extern bool is_inexpensive_builtin (tree);
 
 #endif
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 8e2ad465001c..536e07e38d90 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-02  Andrew MacLeod  <amacleod@redhat.com>
+
+	* c-decl.c: Include builtins.h.
+	* c-parser.c: Likewise.
+
 2014-05-27  Marek Polacek  <polacek@redhat.com>
 
 	PR c/56724
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index e8e6bd2b2219..dc8dbc2fb3c8 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "plugin.h"
 #include "c-family/c-ada-spec.h"
 #include "cilk.h"
+#include "builtins.h"
 
 /* In grokdeclarator, distinguish syntactic contexts of declarators.  */
 enum decl_context
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 88edf36e98ff..1d9780edf4ec 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cgraph.h"
 #include "plugin.h"
 #include "omp-low.h"
+#include "builtins.h"
 
 
 /* Initialization routine for this file.  */
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 934f40d0627b..8b0e466a52f2 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -73,6 +73,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-address.h"
 #include "recog.h"
 #include "output.h"
+#include "builtins.h"
 
 /* Some systems use __main in a way incompatible with its use in gcc, in these
    cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index a1d848696434..bb33304a2fd5 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -64,6 +64,7 @@
 #include "tree-vectorizer.h"
 #include "config/arm/aarch-cost-tables.h"
 #include "dumpfile.h"
+#include "builtins.h"
 
 /* Defined for convenience.  */
 #define POINTER_BYTES (POINTER_SIZE / BITS_PER_UNIT)
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 7663e20ea53a..77ba003add59 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -73,6 +73,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "libfuncs.h"
 #include "opts.h"
 #include "params.h"
+#include "builtins.h"
 
 /* Specify which cpu to schedule for.  */
 enum processor_type alpha_tune;
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 3b3e82080e69..0aa43c2ce2e7 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -66,6 +66,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "context.h"
 #include "pass_manager.h"
 #include "wide-int.h"
+#include "builtins.h"
 
 /* Which cpu we're compiling for (A5, ARC600, ARC601, ARC700).  */
 static const char *arc_cpu_string = "";
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index f8575b9de6a1..98a8d891f23a 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -61,6 +61,7 @@
 #include "opts.h"
 #include "dumpfile.h"
 #include "gimple-expr.h"
+#include "builtins.h"
 
 /* Forward definitions of types.  */
 typedef struct minipool_node    Mnode;
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index 2b6b4878e3ce..9285ccd11489 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -51,6 +51,7 @@
 #include "target-def.h"
 #include "params.h"
 #include "df.h"
+#include "builtins.h"
 
 /* Maximal allowed offset for an address in the LD command */
 #define MAX_LD_OFFSET(MODE) (64 - (signed)GET_MODE_SIZE (MODE))
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 7945de4d8730..35408eb68cf6 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -59,6 +59,7 @@
 #include "hw-doloop.h"
 #include "opts.h"
 #include "dumpfile.h"
+#include "builtins.h"
 
 /* A C structure for machine-specific, per-function data.
    This is added to the cfun structure.  */
diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c
index 339da13e23b3..f0d8cbb42fdd 100644
--- a/gcc/config/c6x/c6x.c
+++ b/gcc/config/c6x/c6x.c
@@ -57,6 +57,7 @@
 #include "regrename.h"
 #include "dumpfile.h"
 #include "gimple-expr.h"
+#include "builtins.h"
 
 /* Table of supported architecture variants.  */
 typedef struct
diff --git a/gcc/config/cr16/cr16.c b/gcc/config/cr16/cr16.c
index f5a444bec48b..e9bfc8917f02 100644
--- a/gcc/config/cr16/cr16.c
+++ b/gcc/config/cr16/cr16.c
@@ -45,6 +45,7 @@
 #include "target.h"
 #include "target-def.h"
 #include "df.h"
+#include "builtins.h"
 
 /* Definitions.  */
 
diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c
index 194dd14f9bfd..cbed2df8ead8 100644
--- a/gcc/config/cris/cris.c
+++ b/gcc/config/cris/cris.c
@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "df.h"
 #include "opts.h"
 #include "cgraph.h"
+#include "builtins.h"
 
 /* Usable when we have an amount to add or subtract, and want the
    optimal size of the insn.  */
diff --git a/gcc/config/epiphany/epiphany.c b/gcc/config/epiphany/epiphany.c
index 598f61b4e52f..5a4d89e4ebc9 100644
--- a/gcc/config/epiphany/epiphany.c
+++ b/gcc/config/epiphany/epiphany.c
@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"	/* for current_pass */
 #include "context.h"
 #include "pass_manager.h"
+#include "builtins.h"
 
 /* Which cpu we're compiling for.  */
 int epiphany_cpu_type;
diff --git a/gcc/config/fr30/fr30.c b/gcc/config/fr30/fr30.c
index 65084f69c1d9..37759cc7bd43 100644
--- a/gcc/config/fr30/fr30.c
+++ b/gcc/config/fr30/fr30.c
@@ -45,6 +45,7 @@
 #include "tm_p.h"
 #include "target.h"
 #include "target-def.h"
+#include "builtins.h"
 
 /*}}}*/
 /*{{{  Function Prologues & Epilogues */ 
diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c
index 2b0a0b233a5c..fda2c1fd857f 100644
--- a/gcc/config/frv/frv.c
+++ b/gcc/config/frv/frv.c
@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "langhooks.h"
 #include "df.h"
 #include "dumpfile.h"
+#include "builtins.h"
 
 #ifndef FRV_INLINE
 #define FRV_INLINE inline
diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c
index e7ed03a6628e..a0ff81b20b19 100644
--- a/gcc/config/h8300/h8300.c
+++ b/gcc/config/h8300/h8300.c
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "target.h"
 #include "target-def.h"
 #include "df.h"
+#include "builtins.h"
 
 /* Classifies a h8300_src_operand or h8300_dst_operand.
 
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6f235f7f5f79..84f79dd1d7fc 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -84,6 +84,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "target-globals.h"
 #include "tree-vectorizer.h"
 #include "shrink-wrap.h"
+#include "builtins.h"
 
 static rtx legitimize_dllimport_symbol (rtx, bool);
 static rtx legitimize_pe_coff_extern_decl (rtx, bool);
diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c
index 03e77aa80a7b..de607179715e 100644
--- a/gcc/config/i386/winnt.c
+++ b/gcc/config/i386/winnt.c
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple.h"
 #include "lto-streamer.h"
 #include "lto-section-names.h"
+#include "builtins.h"
 
 /* i386/PE specific attribute support.
 
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 4c5390b5f0c9..cb9a9ca8af82 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -74,6 +74,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "reload.h"
 #include "opts.h"
 #include "dumpfile.h"
+#include "builtins.h"
 
 /* This is used for communication between ASM_OUTPUT_LABEL and
    ASM_OUTPUT_LABELREF.  */
diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c
index 717df2e9d384..49896e8a198c 100644
--- a/gcc/config/iq2000/iq2000.c
+++ b/gcc/config/iq2000/iq2000.c
@@ -47,6 +47,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "target-def.h"
 #include "langhooks.h"
 #include "df.h"
+#include "builtins.h"
 
 /* Enumeration for all of the relational tests, so that we can build
    arrays indexed by the test type, and not worry about the order
diff --git a/gcc/config/lm32/lm32.c b/gcc/config/lm32/lm32.c
index 4f6aba1e7645..fe3dcf4057f7 100644
--- a/gcc/config/lm32/lm32.c
+++ b/gcc/config/lm32/lm32.c
@@ -50,6 +50,7 @@
 #include "langhooks.h"
 #include "tm-constrs.h"
 #include "df.h"
+#include "builtins.h"
 
 struct lm32_frame_info
 {
diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c
index 75f67f741e23..0d7dcee1bc98 100644
--- a/gcc/config/m32c/m32c.c
+++ b/gcc/config/m32c/m32c.c
@@ -61,6 +61,7 @@
 #include "gimple.h"
 #include "df.h"
 #include "tm-constrs.h"
+#include "builtins.h"
 
 /* Prototypes */
 
diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c
index 2b84b0ff1ebe..71ce534e8020 100644
--- a/gcc/config/m32r/m32r.c
+++ b/gcc/config/m32r/m32r.c
@@ -46,6 +46,7 @@
 #include "target-def.h"
 #include "tm-constrs.h"
 #include "opts.h"
+#include "builtins.h"
 
 /* Array of valid operand punctuation characters.  */
 static char m32r_punct_chars[256];
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index 7f7d668478b3..90ffeb497ad5 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ggc.h"
 #include "opts.h"
 #include "optabs.h"
+#include "builtins.h"
 
 enum reg_class regno_reg_class[] =
 {
diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c
index b2ac47e03fee..717591e43246 100644
--- a/gcc/config/mcore/mcore.c
+++ b/gcc/config/mcore/mcore.c
@@ -46,6 +46,7 @@
 #include "target.h"
 #include "target-def.h"
 #include "df.h"
+#include "builtins.h"
 
 /* For dumping information about frame sizes.  */
 char * mcore_current_function_name = 0;
diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c
index 107f1fa02d7a..558883c47c3b 100644
--- a/gcc/config/mep/mep.c
+++ b/gcc/config/mep/mep.c
@@ -65,6 +65,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "opts.h"
 #include "dumpfile.h"
+#include "builtins.h"
 
 /* Structure of this file:
 
diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
index b12b7bf047f6..cf2dc74cccc0 100644
--- a/gcc/config/microblaze/microblaze.c
+++ b/gcc/config/microblaze/microblaze.c
@@ -51,6 +51,7 @@
 #include "optabs.h"
 #include "diagnostic-core.h"
 #include "cgraph.h"
+#include "builtins.h"
 
 #define MICROBLAZE_VERSION_COMPARE(VA,VB) strcasecmp (VA, VB)
 
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 804112cb074e..0d6bbf16ad1c 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -72,6 +72,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"
 #include "context.h"
 #include "cgraph.h"
+#include "builtins.h"
 
 /* True if X is an UNSPEC wrapper around a SYMBOL_REF or LABEL_REF.  */
 #define UNSPEC_ADDRESS_P(X)					\
diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c
index 9b616eb1efef..e0b8ce76f09e 100644
--- a/gcc/config/mmix/mmix.c
+++ b/gcc/config/mmix/mmix.c
@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "target-def.h"
 #include "df.h"
 #include "tm-constrs.h"
+#include "builtins.h"
 
 /* First some local helper definitions.  */
 #define MMIX_FIRST_GLOBAL_REGNUM 32
diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c
index eb0007767500..d229ca9638b9 100644
--- a/gcc/config/mn10300/mn10300.c
+++ b/gcc/config/mn10300/mn10300.c
@@ -49,6 +49,7 @@
 #include "opts.h"
 #include "cfgloop.h"
 #include "dumpfile.h"
+#include "builtins.h"
 
 /* This is used in the am33_2.0-linux-gnu port, in which global symbol
    names are not prefixed by underscores, to tell whether to prefix a
diff --git a/gcc/config/moxie/moxie.c b/gcc/config/moxie/moxie.c
index a5eaa5f59b0c..1e289068179b 100644
--- a/gcc/config/moxie/moxie.c
+++ b/gcc/config/moxie/moxie.c
@@ -49,6 +49,7 @@
 #include "tm_p.h"
 #include "langhooks.h"
 #include "df.h"
+#include "builtins.h"
 
 #define LOSE_AND_RETURN(msgid, x)		\
   do						\
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index 0f6114c1ee8e..52195c90a7ec 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -51,6 +51,7 @@
 #include "msp430-protos.h"
 #include "dumpfile.h"
 #include "opts.h"
+#include "builtins.h"
 
 
 static void msp430_compute_frame_info (void);
diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c
index 47b1318bb0ea..8516221b25d0 100644
--- a/gcc/config/nds32/nds32.c
+++ b/gcc/config/nds32/nds32.c
@@ -50,6 +50,7 @@
 #include "target-def.h"
 #include "langhooks.h"		/* For add_builtin_function().  */
 #include "ggc.h"
+#include "builtins.h"
 
 /* ------------------------------------------------------------------------ */
 
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
index 95dcbb917cf1..fe3881e80923 100644
--- a/gcc/config/pa/pa.c
+++ b/gcc/config/pa/pa.c
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "langhooks.h"
 #include "df.h"
 #include "opts.h"
+#include "builtins.h"
 
 /* Return nonzero if there is a bypass for the output of 
    OUT_INSN and the fp store IN_INSN.  */
diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c
index 677160aac3df..f10d28a25605 100644
--- a/gcc/config/pdp11/pdp11.c
+++ b/gcc/config/pdp11/pdp11.c
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "df.h"
 #include "opts.h"
 #include "dbxout.h"
+#include "builtins.h"
 
 /* this is the current value returned by the macro FIRST_PARM_OFFSET 
    defined in tm.h */
diff --git a/gcc/config/picochip/picochip.c b/gcc/config/picochip/picochip.c
index 8738564d3fcf..6433acb49d5f 100644
--- a/gcc/config/picochip/picochip.c
+++ b/gcc/config/picochip/picochip.c
@@ -65,6 +65,7 @@ along with GCC; see the file COPYING3.  If not, see
 #include "libfuncs.h"		/* For memcpy_libfuncs, etc. */
 #include "df.h"			/* For df_regs_ever_live_df_regs_ever_live_pp, etc. */
 #include "dbxout.h"
+#include "builtins.h"
 
 
 /* Target AE ISA information. */
diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c
index 09baa76b984b..b9e6d00ad73f 100644
--- a/gcc/config/rl78/rl78.c
+++ b/gcc/config/rl78/rl78.c
@@ -55,6 +55,7 @@
 #include "context.h"
 #include "tm-constrs.h" /* for satisfies_constraint_*().  */
 #include "insn-flags.h" /* for gen_*().  */
+#include "builtins.h"
 
 static inline bool is_interrupt_func (const_tree decl);
 static inline bool is_brk_interrupt_func (const_tree decl);
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 8d8014678191..4dcbaf831538 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -79,6 +79,7 @@
 #include "dumpfile.h"
 #include "cgraph.h"
 #include "target-globals.h"
+#include "builtins.h"
 #if TARGET_XCOFF
 #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
 #endif
diff --git a/gcc/config/rx/rx.c b/gcc/config/rx/rx.c
index c81b2d4a410f..9f834481b4f8 100644
--- a/gcc/config/rx/rx.c
+++ b/gcc/config/rx/rx.c
@@ -55,6 +55,7 @@
 #include "langhooks.h"
 #include "opts.h"
 #include "cgraph.h"
+#include "builtins.h"
 
 static unsigned int rx_gp_base_regnum_val = INVALID_REGNUM;
 static unsigned int rx_pid_base_regnum_val = INVALID_REGNUM;
diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 417e2a826b70..85a6ca9f67f9 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -70,6 +70,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "opts.h"
 #include "tree-pass.h"
 #include "context.h"
+#include "builtins.h"
 
 /* Define the specific costs for a given cpu.  */
 
diff --git a/gcc/config/score/score.c b/gcc/config/score/score.c
index e42960289c7c..576a2a0cde9d 100644
--- a/gcc/config/score/score.c
+++ b/gcc/config/score/score.c
@@ -51,6 +51,7 @@
 #include "langhooks.h"
 #include "df.h"
 #include "opts.h"
+#include "builtins.h"
 
 #define SCORE_SDATA_MAX                score_sdata_max
 #define SCORE_STACK_ALIGN(LOC)         (((LOC) + 3) & ~3)
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index a5118c63f999..caa558ecea5f 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -73,6 +73,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"
 #include "pass_manager.h"
 #include "context.h"
+#include "builtins.h"
 
 int code_for_indirect_jump_scratch = CODE_FOR_indirect_jump_scratch;
 
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 7bfd3c1d73c3..8b1dfa6d3b07 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -70,6 +70,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"
 #include "context.h"
 #include "wide-int.h"
+#include "builtins.h"
 
 /* Processor costs */
 
diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c
index 41d3c2c5e031..a32a3a33bdf7 100644
--- a/gcc/config/spu/spu.c
+++ b/gcc/config/spu/spu.c
@@ -66,6 +66,7 @@
 #include "df.h"
 #include "dumpfile.h"
 #include "cfgloop.h"
+#include "builtins.h"
 
 /* Builtin types, data and prototypes. */
 
diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c
index 6a64fccbe115..1463d52ef01c 100644
--- a/gcc/config/stormy16/stormy16.c
+++ b/gcc/config/stormy16/stormy16.c
@@ -62,6 +62,7 @@
 #include "gimplify.h"
 #include "df.h"
 #include "reload.h"
+#include "builtins.h"
 
 static rtx emit_addhi3_postreload (rtx, rtx, rtx);
 static void xstormy16_asm_out_constructor (rtx, int);
diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c
index 70fce93bd6a4..ab53fab26b8d 100644
--- a/gcc/config/tilegx/tilegx.c
+++ b/gcc/config/tilegx/tilegx.c
@@ -61,6 +61,7 @@
 #include "tilegx-builtins.h"
 #include "tilegx-multiply.h"
 #include "diagnostic.h"
+#include "builtins.h"
 
 /* SYMBOL_REF for GOT */
 static GTY(()) rtx g_got_symbol = NULL;
diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c
index e89a733746b5..1749556a557f 100644
--- a/gcc/config/tilepro/tilepro.c
+++ b/gcc/config/tilepro/tilepro.c
@@ -62,6 +62,7 @@
 #include "tilepro-builtins.h"
 #include "tilepro-multiply.h"
 #include "diagnostic.h"
+#include "builtins.h"
 
 /* SYMBOL_REF for GOT */
 static GTY(()) rtx g_got_symbol = NULL;
diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c
index eb1932657009..e164586bfdcd 100644
--- a/gcc/config/v850/v850.c
+++ b/gcc/config/v850/v850.c
@@ -45,6 +45,7 @@
 #include "target-def.h"
 #include "df.h"
 #include "opts.h"
+#include "builtins.h"
 
 #ifndef streq
 #define streq(a,b) (strcmp (a, b) == 0)
diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c
index 818137baceb4..4897ac2d62cd 100644
--- a/gcc/config/vax/vax.c
+++ b/gcc/config/vax/vax.c
@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "target.h"
 #include "target-def.h"
 #include "wide-int.h"
+#include "builtins.h"
 
 static void vax_option_override (void);
 static bool vax_legitimate_address_p (enum machine_mode, rtx, bool);
diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 6b6693ff3414..540ffecd391d 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple.h"
 #include "gimplify.h"
 #include "df.h"
+#include "builtins.h"
 
 
 /* Enumeration for all of the relational tests, so that we can build
diff --git a/gcc/convert.c b/gcc/convert.c
index b8f36710cdfd..2d9600dd853d 100644
--- a/gcc/convert.c
+++ b/gcc/convert.c
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic-core.h"
 #include "target.h"
 #include "langhooks.h"
+#include "builtins.h"
 #include "ubsan.h"
 
 /* Convert EXPR to some pointer or reference type TYPE.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e8a25f3b9b91..346782e623b7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-02  Andrew MacLeod  <amacleod@redhat.com>
+
+	* decl.c: Include builtins.h.
+	* semantics.c: Likewise.
+
 2014-05-31  Paolo Carlini  <paolo.carlini@oracle.com>
 
 	DR 1227
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e5eecb273789..c61ad68f92bf 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cgraph.h"
 #include "cilk.h"
 #include "wide-int.h"
+#include "builtins.h"
 
 /* Possible cases of bad specifiers type used by bad_specifiers. */
 enum bad_spec_place {
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 396a893bd57e..4c13e9dc7398 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "bitmap.h"
 #include "omp-low.h"
+#include "builtins.h"
 
 static bool verify_constant (tree, bool, bool *, bool *);
 #define VERIFY_CONSTANT(X)						\
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 3bf2ff721369..fe1da9ed8abf 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -57,6 +57,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "df.h"
 #include "params.h"
 #include "target.h"
+#include "builtins.h"
 
 struct target_rtl default_target_rtl;
 #if SWITCHABLE_TARGET
diff --git a/gcc/except.c b/gcc/except.c
index fe1de06a12e9..018439e9e100 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -141,6 +141,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"
 #include "pointer-set.h"
 #include "cfgloop.h"
+#include "builtins.h"
 
 /* Provide defaults for stuff that may not be defined when using
    sjlj exceptions.  */
diff --git a/gcc/expr.c b/gcc/expr.c
index d99bc1ef9fba..512c024e6989 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -67,6 +67,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "tree-ssa-address.h"
 #include "cfgexpand.h"
+#include "builtins.h"
 
 #ifndef STACK_PUSH_CODE
 #ifdef STACK_GROWS_DOWNWARD
diff --git a/gcc/expr.h b/gcc/expr.h
index 1823febac265..6a1d3ab5709e 100644
--- a/gcc/expr.h
+++ b/gcc/expr.h
@@ -252,20 +252,6 @@ extern unsigned HOST_WIDE_INT choose_multiplier (unsigned HOST_WIDE_INT, int,
 						 int, unsigned HOST_WIDE_INT *,
 						 int *, int *);
 
-/* Functions from builtins.c:  */
-extern rtx expand_builtin (tree, rtx, rtx, enum machine_mode, int);
-extern tree std_build_builtin_va_list (void);
-extern tree std_fn_abi_va_list (tree);
-extern tree std_canonical_va_list_type (tree);
-
-extern void std_expand_builtin_va_start (tree, rtx);
-extern rtx default_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
-extern void expand_builtin_setjmp_setup (rtx, rtx);
-extern void expand_builtin_setjmp_receiver (rtx);
-extern rtx expand_builtin_saveregs (void);
-extern void expand_builtin_trap (void);
-extern rtx builtin_strncpy_read_str (void *, HOST_WIDE_INT, enum machine_mode);
-
 /* Functions from expr.c:  */
 
 /* This is run during target initialization to set up which modes can be
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 0451b6a90bee..24daaa32ce3b 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -68,6 +68,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "tree-dfa.h"
 #include "hash-table.h"  /* Required for ENABLE_FOLD_CHECKING.  */
+#include "builtins.h"
 
 /* Nonzero if we are folding constants inside an initializer; zero
    otherwise.  */
diff --git a/gcc/fold-const.h b/gcc/fold-const.h
index 023f043853e5..dcb97a17a310 100644
--- a/gcc/fold-const.h
+++ b/gcc/fold-const.h
@@ -85,7 +85,6 @@ extern void fold_defer_overflow_warnings (void);
 extern void fold_undefer_overflow_warnings (bool, const_gimple, int);
 extern void fold_undefer_and_ignore_overflow_warnings (void);
 extern bool fold_deferring_overflow_warnings_p (void);
-extern tree fold_fma (location_t, tree, tree, tree, tree);
 extern int operand_equal_p (const_tree, const_tree, unsigned int);
 extern int multiple_of_p (tree, const_tree, const_tree);
 #define omit_one_operand(T1,T2,T3)\
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 831103a3a89d..5aa0979e5633 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-02  Andrew MacLeod  <amacleod@redhat.com>
+
+	* fortran/trans.c (trans_runtime_error_vararg): Call
+	fold_build_call_array_loc instead of fold_builtin_call_array.
+
 2014-06-02  Bernd Schmidt  <bernds@codesourcery.com>
 
 	* trans-decl.c (gfc_build_builtin_function_decls): Correct number of
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index 8182da541411..cfb8038440b8 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -450,13 +450,13 @@ trans_runtime_error_vararg (bool error, locus* where, const char* msgid,
     fntype = TREE_TYPE (gfor_fndecl_runtime_warning_at);
 
   loc = where ? where->lb->location : input_location;
-  tmp = fold_builtin_call_array (loc, TREE_TYPE (fntype),
-				 fold_build1_loc (loc, ADDR_EXPR,
+  tmp = fold_build_call_array_loc (loc, TREE_TYPE (fntype),
+				   fold_build1_loc (loc, ADDR_EXPR,
 					     build_pointer_type (fntype),
 					     error
 					     ? gfor_fndecl_runtime_error_at
 					     : gfor_fndecl_runtime_warning_at),
-				 nargs + 2, argarray);
+				   nargs + 2, argarray);
   gfc_add_expr_to_block (&block, tmp);
 
   return gfc_finish_block (&block);
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index a9c01bd2560c..403dee707a32 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "langhooks.h"
 #include "gimplify-me.h"
 #include "dbgcnt.h"
+#include "builtins.h"
 
 /* Return true when DECL can be referenced from current unit.
    FROM_DECL (if non-null) specify constructor of variable DECL was taken from.
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index a41d9722dae1..fae2c562b324 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -64,6 +64,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-address.h"
 #include "tree-affine.h"
 #include "wide-int-print.h"
+#include "builtins.h"
 
 /* Information about a strength reduction candidate.  Each statement
    in the candidate table represents an expression of one of the
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 654b05c09c97..92714b595494 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -62,6 +62,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "langhooks-def.h"	/* FIXME: for lhd_set_decl_assembler_name */
 #include "tree-pass.h"		/* FIXME: only for PROP_gimple_any */
+#include "builtins.h"
 
 enum gimplify_omp_var_data
 {
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog
index 8374c7adc1b9..d66b753a68b3 100644
--- a/gcc/go/ChangeLog
+++ b/gcc/go/ChangeLog
@@ -1,3 +1,7 @@
+2014-06-02  Andrew MacLeod  <amacleod@redhat.com>
+
+	* go-gcc.cc: Include builtins.h.
+
 2014-05-17  Trevor Saunders  <tsaunders@mozilla.com>
 
 	* go-lang.c (struct GTY): Don't use variable_size gty attribute.
diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index fc100e2389cd..5b95e5d133a2 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -39,6 +39,7 @@
 #include "output.h"
 #include "real.h"
 #include "realmpfr.h"
+#include "builtins.h"
 
 #include "go-c.h"
 
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index e09c5cdb5456..82bbd7f14ddc 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -122,6 +122,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-utils.h"
 #include "sreal.h"
 #include "cilk.h"
+#include "builtins.h"
 
 /* Statistics we collect about inlining algorithm.  */
 static int overall_size;
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 5c1802cd442b..167082160ebb 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssanames.h"
 #include "dbgcnt.h"
 #include "domwalk.h"
+#include "builtins.h"
 
 /* Intermediate information that we get from alias analysis about a particular
    parameter in a particular basic_block.  When a parameter or the memory it
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 034d9d93e8fa..64e4f4b4530d 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-streamer.h"
 #include "streamer-hooks.h"
 #include "cfgloop.h"
+#include "builtins.h"
 
 
 static void lto_write_tree (struct output_block*, tree, bool);
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 6985c395dbc1..87a8deafaf11 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,7 @@
+2014-06-02  Andrew MacLeod  <amacleod@redhat.com>
+
+	* lto-symtab.c: Include builtins.h.
+
 2014-05-26  Richard Biener  <rguenther@suse.de>
 
 	* lto.c (lto_parse_hex): Use int64_t.
diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index 7f48c5e9a8ea..571b2dd386d2 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "lto-streamer.h"
 #include "ipa-utils.h"
 #include "ipa-inline.h"
+#include "builtins.h"
 
 /* Replace the cgraph node NODE with PREVAILING_NODE in the cgraph, merging
    all edges and removing the old node.  */
diff --git a/gcc/realmpfr.h b/gcc/realmpfr.h
index 0595f39b9977..d909dba2d03f 100644
--- a/gcc/realmpfr.h
+++ b/gcc/realmpfr.h
@@ -25,9 +25,6 @@
 #include <mpc.h>
 #include "real.h"
 
-/* In builtins.c.  */
-extern tree do_mpc_arg2 (tree, tree, tree, int, int (*)(mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t));
-
 /* Convert between MPFR and REAL_VALUE_TYPE.  The caller is
    responsible for initializing and clearing the MPFR parameter.  */
 
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 722d34f54efc..7c1ea5d5cb9f 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -59,6 +59,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "pretty-print.h"
 #include "params.h"
 #include "dumpfile.h"
+#include "builtins.h"
 
 
 /* Functions and data structures for expanding case statements.  */
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 3df93d394322..dfbd2543086f 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -1322,6 +1322,31 @@ default_have_conditional_execution (void)
 #endif
 }
 
+/* By default we assume that c99 functions are present at the runtime,
+   but sincos is not.  */
+bool
+default_libc_has_function (enum function_class fn_class)
+{
+  if (fn_class == function_c94
+      || fn_class == function_c99_misc
+      || fn_class == function_c99_math_complex)
+    return true;
+
+  return false;
+}
+
+bool
+gnu_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
+{
+  return true;
+}
+
+bool
+no_c99_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
+{
+  return false;
+}
+
 tree
 default_builtin_tm_load_store (tree ARG_UNUSED (type))
 {
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 3208c7403f4f..7e75cce662f0 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -67,6 +67,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"
 #include "target.h"
 #include "cfgloop.h"
+#include "builtins.h"
 
 #include "rtl.h"	/* FIXME: For asm_str_count.  */
 
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index 3c606b02d41a..93f8373f92af 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-propagate.h"
 #include "tree-phinodes.h"
 #include "ssa-iterators.h"
+#include "builtins.h"
 
 struct object_size_info
 {
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index ef6c96672aae..db91c8b81753 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -112,6 +112,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-pretty-print.h"
 #include "ipa-inline.h"
 #include "ipa-utils.h"
+#include "builtins.h"
 
 /* Enumeration of all aggregate reductions we can do.  */
 enum sra_mode { SRA_MODE_EARLY_IPA,   /* early call regularization */
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index d7410122c460..66b897743ece 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -154,6 +154,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "dbgcnt.h"
 #include "params.h"
 #include "wide-int-print.h"
+#include "builtins.h"
 
 
 /* Possible lattice values.  */
diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c
index e863567efb4e..33fede2665ad 100644
--- a/gcc/tree-ssa-forwprop.c
+++ b/gcc/tree-ssa-forwprop.c
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "optabs.h"
 #include "tree-ssa-propagate.h"
 #include "tree-ssa-dom.h"
+#include "builtins.h"
 
 /* This pass propagates the RHS of assignment statements into use
    sites of the LHS of the assignment.  It's basically a specialized
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index e332918fd16b..1bbc1cd3b6a9 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -68,6 +68,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-inline.h"
 #include "target.h"
 #include "tree-cfgcleanup.h"
+#include "builtins.h"
 
 /* Specifies types of loops that may be unrolled.  */
 
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index b24463df4081..7546ff6fe836 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -109,6 +109,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-propagate.h"
 #include "expmed.h"
 #include "tree-ssa-address.h"
+#include "builtins.h"
 
 /* FIXME: Expressions are expanded to RTL in this pass to determine the
    cost of different addressing modes.  This should be moved to a TBD
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index d9afccff6a5e..68dfa17b85e0 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -114,6 +114,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "alloc-pool.h"
 #include "target.h"
 #include "gimple-pretty-print.h"
+#include "builtins.h"
 
 /* FIXME: RTL headers have to be included here for optabs.  */
 #include "rtl.h"		/* Because optabs.h wants enum rtx_code.  */
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 357ac08381cc..3d811f068939 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -60,6 +60,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "target.h"
 #include "params.h"
 #include "diagnostic-core.h"
+#include "builtins.h"
 
 /*  This is a simple global reassociation pass.  It is, in part, based
     on the LLVM pass of the same name (They do some things more/less
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index 8e628d5535da..69e5a6b5629e 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "langhooks.h"
 #include "params.h"
 #include "tree-ssa-threadedge.h"
+#include "builtins.h"
 
 /* To avoid code explosion due to jump threading, we limit the
    number of statements we are going to copy.  This variable
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index 86ebe205b4aa..da7c096b8261 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "data-streamer.h"
 #include "streamer-hooks.h"
 #include "lto-streamer.h"
+#include "builtins.h"
 
 /* Read a STRING_CST from the string table in DATA_IN using input
    block IB.  */
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index c48640550e7d..a4c439fb19ad 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -57,6 +57,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Need to include rtl.h, expr.h, etc. for optabs.  */
 #include "expr.h"
 #include "optabs.h"
+#include "builtins.h"
 
 /* Return true if load- or store-lanes optab OPTAB is implemented for
    COUNT vectors of type VECTYPE.  NAME is the name of OPTAB.  */
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 3d57eaba411b..b504f4241db4 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "recog.h"		/* FIXME: for insn_data */
 #include "diagnostic-core.h"
 #include "dumpfile.h"
+#include "builtins.h"
 
 /* Pattern recognition functions  */
 static gimple vect_recog_widen_sum_pattern (vec<gimple> *, tree *,
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index ec9cc68bfabb..8c61775897da 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-vectorizer.h"
 #include "dumpfile.h"
 #include "cgraph.h"
+#include "builtins.h"
 
 /* For lang_hooks.types.type_for_mode.  */
 #include "langhooks.h"
diff --git a/gcc/tree.c b/gcc/tree.c
index cf7e362eff34..de16549a099f 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -76,6 +76,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "debug.h"
 #include "intl.h"
 #include "wide-int.h"
+#include "builtins.h"
 
 /* Tree code classes.  */
 
@@ -10467,6 +10468,91 @@ build_call_vec (tree return_type, tree fn, vec<tree, va_gc> *args)
   return ret;
 }
 
+/* Conveniently construct a function call expression.  FNDECL names the
+   function to be called and N arguments are passed in the array
+   ARGARRAY.  */
+
+tree
+build_call_expr_loc_array (location_t loc, tree fndecl, int n, tree *argarray)
+{
+  tree fntype = TREE_TYPE (fndecl);
+  tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl);
+ 
+  return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, n, argarray);
+}
+
+/* Conveniently construct a function call expression.  FNDECL names the
+   function to be called and the arguments are passed in the vector
+   VEC.  */
+
+tree
+build_call_expr_loc_vec (location_t loc, tree fndecl, vec<tree, va_gc> *vec)
+{
+  return build_call_expr_loc_array (loc, fndecl, vec_safe_length (vec),
+				    vec_safe_address (vec));
+}
+
+
+/* Conveniently construct a function call expression.  FNDECL names the
+   function to be called, N is the number of arguments, and the "..."
+   parameters are the argument expressions.  */
+
+tree
+build_call_expr_loc (location_t loc, tree fndecl, int n, ...)
+{
+  va_list ap;
+  tree *argarray = XALLOCAVEC (tree, n);
+  int i;
+
+  va_start (ap, n);
+  for (i = 0; i < n; i++)
+    argarray[i] = va_arg (ap, tree);
+  va_end (ap);
+  return build_call_expr_loc_array (loc, fndecl, n, argarray);
+}
+
+/* Like build_call_expr_loc (UNKNOWN_LOCATION, ...).  Duplicated because
+   varargs macros aren't supported by all bootstrap compilers.  */
+
+tree
+build_call_expr (tree fndecl, int n, ...)
+{
+  va_list ap;
+  tree *argarray = XALLOCAVEC (tree, n);
+  int i;
+
+  va_start (ap, n);
+  for (i = 0; i < n; i++)
+    argarray[i] = va_arg (ap, tree);
+  va_end (ap);
+  return build_call_expr_loc_array (UNKNOWN_LOCATION, fndecl, n, argarray);
+}
+
+/* Create a new constant string literal and return a char* pointer to it.
+   The STRING_CST value is the LEN characters at STR.  */
+tree
+build_string_literal (int len, const char *str)
+{
+  tree t, elem, index, type;
+
+  t = build_string (len, str);
+  elem = build_type_variant (char_type_node, 1, 0);
+  index = build_index_type (size_int (len - 1));
+  type = build_array_type (elem, index);
+  TREE_TYPE (t) = type;
+  TREE_CONSTANT (t) = 1;
+  TREE_READONLY (t) = 1;
+  TREE_STATIC (t) = 1;
+
+  type = build_pointer_type (elem);
+  t = build1 (ADDR_EXPR, type,
+	      build4 (ARRAY_REF, elem,
+		      t, integer_zero_node, NULL_TREE, NULL_TREE));
+  return t;
+}
+
+
+
 /* Return true if T (assumed to be a DECL) must be assigned a memory
    location.  */
 
diff --git a/gcc/tree.h b/gcc/tree.h
index 9fe73601aad8..5392fddfef7c 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -3624,6 +3624,11 @@ extern tree build_call_valist (tree, tree, int, va_list);
    build_call_array_loc (UNKNOWN_LOCATION, T1, T2, N, T3)
 extern tree build_call_array_loc (location_t, tree, tree, int, const tree *);
 extern tree build_call_vec (tree, tree, vec<tree, va_gc> *);
+extern tree build_call_expr_loc_array (location_t, tree, int, tree *);
+extern tree build_call_expr_loc_vec (location_t, tree, vec<tree, va_gc> *);
+extern tree build_call_expr_loc (location_t, tree, int, ...);
+extern tree build_call_expr (tree, int, ...);
+extern tree build_string_literal (int, const char *);
 
 /* Construct various nodes representing data types.  */
 
@@ -4745,46 +4750,4 @@ extern tree get_inner_reference (tree, HOST_WIDE_INT *, HOST_WIDE_INT *,
    EXP, an ARRAY_REF or an ARRAY_RANGE_REF.  */
 extern tree array_ref_low_bound (tree);
 
-/* In builtins.c.  */
-
-/* Non-zero if __builtin_constant_p should be folded right away.  */
-extern bool force_folding_builtin_constant_p;
-
-extern bool avoid_folding_inline_builtin (tree);
-extern tree fold_call_expr (location_t, tree, bool);
-extern tree fold_builtin_fputs (location_t, tree, tree, bool, bool, tree);
-extern tree fold_builtin_strcpy (location_t, tree, tree, tree, tree);
-extern tree fold_builtin_strncpy (location_t, tree, tree, tree, tree, tree);
-extern tree fold_builtin_strcat (location_t, tree, tree, tree);
-extern tree fold_builtin_memory_chk (location_t, tree, tree, tree, tree, tree, tree, bool,
-				     enum built_in_function);
-extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, tree, bool,
-				     enum built_in_function);
-extern tree fold_builtin_stxncpy_chk (location_t, tree, tree, tree, tree, tree, bool,
-				      enum built_in_function);
-extern tree fold_builtin_expect (location_t, tree, tree, tree);
-extern bool fold_builtin_next_arg (tree, bool);
-extern enum built_in_function builtin_mathfn_code (const_tree);
-extern tree fold_builtin_call_array (location_t, tree, tree, int, tree *);
-extern tree build_call_expr_loc_array (location_t, tree, int, tree *);
-extern tree build_call_expr_loc_vec (location_t, tree, vec<tree, va_gc> *);
-extern tree build_call_expr_loc (location_t, tree, int, ...);
-extern tree build_call_expr (tree, int, ...);
-extern tree mathfn_built_in (tree, enum built_in_function fn);
-extern tree c_strlen (tree, int);
-extern tree build_string_literal (int, const char *);
-extern rtx builtin_memset_read_str (void *, HOST_WIDE_INT, enum machine_mode);
-extern bool is_builtin_fn (tree);
-extern bool get_object_alignment_1 (tree, unsigned int *,
-				    unsigned HOST_WIDE_INT *);
-extern unsigned int get_object_alignment (tree);
-extern bool get_pointer_alignment_1 (tree, unsigned int *,
-				     unsigned HOST_WIDE_INT *);
-extern unsigned int get_pointer_alignment (tree);
-extern tree fold_call_stmt (gimple, bool);
-extern tree gimple_fold_builtin_snprintf_chk (gimple, tree, enum built_in_function);
-extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
-extern bool is_simple_builtin (tree);
-extern bool is_inexpensive_builtin (tree);
-
 #endif  /* GCC_TREE_H  */
-- 
GitLab