Index: gcc/doc/configfiles.texi =================================================================== --- gcc/doc/configfiles.texi (revision 177990) +++ gcc/doc/configfiles.texi (working copy) @@ -60,5 +60,17 @@ machine. @item @file{tm_p.h}, which includes the header @file{@var{machine}-protos.h} that contains prototypes for functions in the target @file{.c} file. -FIXME: why is such a separate header necessary? +The @file{tm_p.h} is needed because the @file{@var{machine}-protos.h} +will often times include declarations that include RTL and TREE +datatypes. These references must be bracketed with @code{#ifdef +RTX_CODE} and @code{#ifdef TREE_CODE} respecitively. These +declarations can't go in the normal @file{@var{machine}.h} file +because that file is included before @file{rtl.h} and/or @file{tree.h} +are included. The @file{tm_p.h} is included after @file{rtl.h} or +@file{tree.h} are included. +@item +@file{tm-bu-funcs.def}, includes the machine dependent builtin +functions that use the @code{DEF_BUILTIN_MD} macro to reserve the +machine dependent builtins in the master builtin enum list after the +standard enumerations. @end itemize Index: gcc/tree.h =================================================================== --- gcc/tree.h (revision 177990) +++ gcc/tree.h (working copy) @@ -3503,7 +3503,7 @@ struct GTY(()) tree_function_decl { DECL_FUNCTION_CODE. Otherwise unused. ??? The bitfield needs to be able to hold all target function codes as well. */ - ENUM_BITFIELD(built_in_function) function_code : 11; + ENUM_BITFIELD(built_in_function) function_code : 12; ENUM_BITFIELD(built_in_class) built_in_class : 2; unsigned static_ctor_flag : 1; @@ -3526,7 +3526,7 @@ struct GTY(()) tree_function_decl { unsigned looping_const_or_pure_flag : 1; unsigned has_debug_args_flag : 1; - /* 2 bits left */ + /* 1 bit left */ }; /* The source language of the translation-unit. */ Index: gcc/configure =================================================================== --- gcc/configure (revision 177990) +++ gcc/configure (working copy) @@ -608,6 +608,7 @@ PPLINC PPLLIBS GMPINC GMPLIBS +tm_builtin_funcs target_cpu_default fortran_target_objs cxx_target_objs @@ -17913,7 +17914,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17916 "configure" +#line 17917 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18019,7 +18020,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18022 "configure" +#line 18023 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -26796,6 +26797,7 @@ fi + # Echo link setup. if test x${build} = x${host} ; then if test x${host} = x${target} ; then Index: gcc/builtins.def =================================================================== --- gcc/builtins.def (revision 177990) +++ gcc/builtins.def (working copy) @@ -134,6 +134,13 @@ along with GCC; see the file COPYING3. DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, 0, 0, false, false, \ false, 0, false, false) +/* Allocate the enum and the name for a machine dependent builtin, but do not + actually define it here at all. */ +#undef DEF_BUILTIN_MD +#define DEF_BUILTIN_MD(ENUM, NAME) \ + DEF_BUILTIN (ENUM, NAME, BUILT_IN_MD, 0, 0, false, false, \ + false, 0, false, false) + /* Builtin used by the implementation of GNU OpenMP. None of these are actually implemented in the compiler; they're all in libgomp. */ #undef DEF_GOMP_BUILTIN @@ -173,6 +180,10 @@ along with GCC; see the file COPYING3. #undef ATTR_MATHFN_FPROUNDING_STORE #define ATTR_MATHFN_FPROUNDING_STORE ATTR_NOTHROW_LEAF_LIST +/* Avoid problems with fields that are zeroed by making sure index 0 is not a + legitimate builtin. */ +DEF_BUILTIN_STUB (BUILT_IN_NONE, (const char *)0) + /* Category: math builtins. */ DEF_LIB_BUILTIN (BUILT_IN_ACOS, "acos", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO) DEF_C99_C90RES_BUILTIN (BUILT_IN_ACOSF, "acosf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO) @@ -789,3 +800,6 @@ DEF_BUILTIN_STUB (BUILT_IN_EH_COPY_VALUE /* OpenMP builtins. */ #include "omp-builtins.def" + +/* Target machine builtins. */ +#include "tm-bu-funcs.def" Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 177990) +++ gcc/configure.ac (working copy) @@ -4923,6 +4923,7 @@ AC_SUBST(c_target_objs) AC_SUBST(cxx_target_objs) AC_SUBST(fortran_target_objs) AC_SUBST(target_cpu_default) +AC_SUBST(tm_builtin_funcs) AC_SUBST_FILE(language_hooks) Index: gcc/lto/Make-lang.in =================================================================== --- gcc/lto/Make-lang.in (revision 177990) +++ gcc/lto/Make-lang.in (working copy) @@ -79,7 +79,8 @@ $(LTO_EXE): $(LTO_OBJS) $(BACKEND) $(LIB lto/lto-lang.o: lto/lto-lang.c $(CONFIG_H) coretypes.h debug.h \ flags.h $(GGC_H) langhooks.h $(LANGHOOKS_DEF_H) $(SYSTEM_H) \ $(TARGET_H) $(LTO_H) $(GIMPLE_H) gtype-lto.h gt-lto-lto-lang.h \ - $(EXPR_H) $(LTO_STREAMER_H) + $(EXPR_H) $(LTO_STREAMER_H) builtin-attrs.def builtin-types.def \ + $(BUILTINS_DEF) lto/lto.o: lto/lto.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(OPTS_H) \ toplev.h $(TREE_H) $(TREE_FLOW_H) $(DIAGNOSTIC_CORE_H) $(TM_H) \ $(CGRAPH_H) $(GGC_H) tree-ssa-operands.h $(TREE_PASS_H) \ Index: gcc/config.gcc =================================================================== --- gcc/config.gcc (revision 177990) +++ gcc/config.gcc (working copy) @@ -186,7 +186,10 @@ # configure_default_options # Set to an initializer for configure_default_options # in configargs.h, based on --with-cpu et cetera. - +# +# tm_builtin_funcs Set to additional files in the target directory to +# provide target specific builtin functions. +# # The following variables are used in each case-construct to build up the # outgoing variables: # @@ -238,6 +241,7 @@ default_gnu_indirect_function=no target_gtfiles= need_64bit_hwint= need_64bit_isa= +tm_builtin_funcs= # Don't carry these over build->host->target. Please. xm_file= Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in (revision 177990) +++ gcc/Makefile.in (working copy) @@ -909,7 +909,9 @@ RTL_H = $(RTL_BASE_H) genrtl.h vecir.h RTL_ERROR_H = $(RTL_H) $(DIAGNOSTIC_CORE_H) READ_MD_H = $(OBSTACK_H) $(HASHTAB_H) read-md.h PARAMS_H = params.h params.def -BUILTINS_DEF = builtins.def sync-builtins.def omp-builtins.def +BUILTIN_FUNCS_MD = @tm_builtin_funcs@ +BUILTINS_DEF = builtins.def sync-builtins.def omp-builtins.def \ + tm-bu-funcs.def $(BUILTIN_FUNCS_MD) INTERNAL_FN_DEF = internal-fn.def INTERNAL_FN_H = internal-fn.h $(INTERNAL_FN_DEF) TREE_H = tree.h all-tree.def tree.def c-family/c-common.def \ @@ -1979,6 +1981,19 @@ $(T)crtbeginT.o: crtstuff.c $(GCC_PASSES $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O \ -o $(T)crtbeginT$(objext) + +# Build the builtin include files that includes the standard builtin file along +# with any machine dependent versions of those files. Note, this files is +# expected to be included multiple times, so don't use mkconfig.sh which adds +# header guards +tm-bu-funcs.def: s-bu-funcs; @true +s-bu-funcs: Makefile + for inc in $(BUILTIN_FUNCS_MD); do \ + echo "#include \"$$inc\""; \ + done > tmp-bu-funcs.def + $(SHELL) $(srcdir)/../move-if-change tmp-bu-funcs.def tm-bu-funcs.def + $(STAMP) s-bu-funcs + # # Compiling object files from source files. @@ -4511,6 +4526,8 @@ mostlyclean: lang.mostlyclean -rm -f gtype.state # Delete genchecksum outputs -rm -f *-checksum.c +# Delete builtin types, attributes, function include files + -rm -f tm-bu-funcs.def # Delete all files made by compilation # that don't exist in the distribution.