+2011-04-06 Joseph Myers <joseph@codesourcery.com>
+
+ * doc/tm.texi.in: Document C target hooks as separate from general
+ target hooks.
+ * doc/tm.texi: Regenerate.
+ * genhooks.c (struct hook_desc): Add docname field.
+ (HOOK_VECTOR_1, DEFHOOKPOD, DEFHOOK, DEFHOOK_UNDOC). Initialize
+ docname field.
+ (hook_array): Include c-target.def.
+ (emit_documentation): Use docname field in output.
+ (emit_init_macros): Take docname argument. Only emit definitions
+ for hooks matching docname.
+ (main): Expect additional arguments in all cases. Pass argument
+ to emit_init_macros.
+ * target.def: Move initial macro definitions and comments to
+ target-hooks-macros.h.
+ (gcc_targetcm): Move to c-family/c-target.def.
+ * target.h (targetcm): Move declaration to c-family/c-target.h.
+ * targhooks.c (default_handle_c_option): Move to
+ c-family/c-opts.c.
+ * targhooks.h (default_handle_c_option): Move declaration to
+ c-family/c-common.h.
+ * target-hooks-macros.h: New file.
+ * config.gcc (target_has_targetcm): Define and use to add to
+ c_target_objs and cxx_target_objs.
+ * config/default-c.c: New file.
+ * config/darwin-c.c: Include c-target.h and c-target-def.h instead
+ of target.h and target-def.h.
+ (TARGET_HANDLE_C_OPTION, targetcm): Define later in file.
+ (darwin_objc_construct_string, darwin_cfstring_ref_p,
+ darwin_check_cfstring_format_arg): Make static.
+ (TARGET_OBJC_CONSTRUCT_STRING_OBJECT,
+ TARGET_STRING_OBJECT_REF_TYPE_P,
+ TARGET_CHECK_STRING_OBJECT_FORMAT_ARG): Define here.
+ * config/darwin-protos.h (darwin_objc_construct_string,
+ darwin_cfstring_ref_p, darwin_check_cfstring_format_arg): Don't
+ declare.
+ * config/darwin.h (TARGET_OBJC_CONSTRUCT_STRING_OBJECT,
+ TARGET_STRING_OBJECT_REF_TYPE_P,
+ TARGET_CHECK_STRING_OBJECT_FORMAT_ARG, TARGET_HAS_TARGETCM):
+ Remove.
+ * config/t-darwin (darwin-c.o): Update dependencies.
+ * system.h (TARGET_HAS_TARGETCM): Poison.
+ * Makefile.in (TARGET_H): Update.
+ (TARGET_DEF, C_TARGET_DEF, C_TARGET_H, C_TARGET_DEF_H): Define.
+ (c-family/c-format.o, c-family/c-opts.o): Update dependencies.
+ (default-c.o): New target.
+ (s-target-hooks-def-h): Pass "Target Hook" string to genhooks.
+ (c-family/c-target-hooks-def.h, s-c-target-hooks-def-h): New
+ targets.
+ (s-tm-texi): Pass -d option to genhooks. Also test timestamp on
+ c-target.def.
+ (build/genhooks.o): Update dependencies.
+
2011-04-06 Richard Guenther <rguenther@suse.de>
* ipa-inline.c (enum inlining_mode): Remove.
# Shorthand variables for dependency lists.
VEC_H = vec.h statistics.h
EXCEPT_H = except.h $(HASHTAB_H) vecprim.h vecir.h
-TARGET_H = $(TM_H) target.h target.def insn-modes.h
+TARGET_DEF = target.def target-hooks-macros.h
+C_TARGET_DEF = c-family/c-target.def target-hooks-macros.h
+TARGET_H = $(TM_H) target.h $(TARGET_DEF) insn-modes.h
+C_TARGET_H = c-family/c-target.h $(C_TARGET_DEF)
MACHMODE_H = machmode.h mode-classes.def insn-modes.h
HOOKS_H = hooks.h $(MACHMODE_H)
HOSTHOOKS_DEF_H = hosthooks-def.h $(HOOKS_H)
LANGHOOKS_DEF_H = langhooks-def.h $(HOOKS_H)
TARGET_DEF_H = target-def.h target-hooks-def.h $(HOOKS_H) targhooks.h
+C_TARGET_DEF_H = c-family/c-target-def.h c-family/c-target-hooks-def.h \
+ $(TREE_H) $(C_COMMON_H) $(HOOKS_H)
RTL_BASE_H = rtl.h rtl.def $(MACHMODE_H) reg-notes.def insn-notes.def \
$(INPUT_H) $(REAL_H) statistics.h $(VEC_H) $(FIXED_VALUE_H) alias.h \
$(HASHTAB_H)
c-family/c-format.o : c-family/c-format.c c-family/c-format.h \
$(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) langhooks.h \
- $(C_COMMON_H) $(FLAGS_H) intl.h \
+ $(C_COMMON_H) $(FLAGS_H) intl.h $(C_TARGET_H) \
$(DIAGNOSTIC_CORE_H) alloc-pool.h c-family/c-objc.h
c-family/c-gimplify.o : c-family/c-gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
c-family/c-opts.o : c-family/c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TREE_H) $(C_PRAGMA_H) $(FLAGS_H) toplev.h langhooks.h \
- $(DIAGNOSTIC_H) intl.h debug.h $(C_COMMON_H) \
+ $(DIAGNOSTIC_H) intl.h debug.h $(C_COMMON_H) $(C_TARGET_H) \
$(OPTS_H) $(OPTIONS_H) $(MKDEPS_H) incpath.h cppdefault.h
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
$< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@
c-family/stub-objc.o : c-family/stub-objc.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(TREE_H) $(C_COMMON_H) c-family/c-objc.h
+default-c.o: config/default-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
+ $(C_TARGET_H) $(C_TARGET_DEF_H)
+ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
+ $< $(OUTPUT_OPTION)
# Files used by all variants of C and some other languages.
$(srcdir)/doc/tm.texi: s-tm-texi; @true
s-target-hooks-def-h: build/genhooks$(build_exeext)
- $(RUN_GEN) build/genhooks$(build_exeext) > tmp-target-hooks-def.h
+ $(RUN_GEN) build/genhooks$(build_exeext) "Target Hook" \
+ > tmp-target-hooks-def.h
$(SHELL) $(srcdir)/../move-if-change tmp-target-hooks-def.h \
target-hooks-def.h
$(STAMP) s-target-hooks-def-h
+c-family/c-target-hooks-def.h: s-c-target-hooks-def-h; @true
+
+s-c-target-hooks-def-h: build/genhooks$(build_exeext)
+ $(RUN_GEN) build/genhooks$(build_exeext) "C Target Hook" \
+ > tmp-c-target-hooks-def.h
+ $(SHELL) $(srcdir)/../move-if-change tmp-c-target-hooks-def.h \
+ c-family/c-target-hooks-def.h
+ $(STAMP) s-c-target-hooks-def-h
+
# check if someone mistakenly only changed tm.texi.
# We use a different pathname here to avoid a circular dependency.
s-tm-texi: $(srcdir)/doc/../doc/tm.texi
# \r is not portable to Solaris tr, therefore we have a special
# case for ASCII. We use \r for other encodings like EBCDIC.
s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
- $(RUN_GEN) build/genhooks$(build_exeext) \
+ $(RUN_GEN) build/genhooks$(build_exeext) -d \
$(srcdir)/doc/tm.texi.in > tmp-tm.texi
case `echo X|tr X '\101'` in \
A) tr -d '\015' < tmp-tm.texi > tmp2-tm.texi ;; \
@if cmp -s $(srcdir)/doc/tm.texi tm.texi; then \
$(STAMP) $@; \
elif test $(srcdir)/doc/tm.texi -nt $(srcdir)/doc/tm.texi.in \
- && test $(srcdir)/doc/tm.texi -nt $(srcdir)/target.def; then \
+ && ( test $(srcdir)/doc/tm.texi -nt $(srcdir)/target.def \
+ || test $(srcdir)/doc/tm.texi -nt $(srcdir)/c-family/c-target.def \
+ ); then \
echo >&2 ; \
echo You should edit $(srcdir)/doc/tm.texi.in rather than $(srcdir)/doc/tm.texi . >&2 ; \
false; \
coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h $(OBSTACK_H)
build/genrecog.o : genrecog.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
-build/genhooks.o : genhooks.c target.def $(BCONFIG_H) $(SYSTEM_H) errors.h
+build/genhooks.o : genhooks.c $(TARGET_DEF) $(C_TARGET_DEF) \
+ $(BCONFIG_H) $(SYSTEM_H) errors.h
# Compile the programs that generate insn-* from the machine description.
# They are compiled with $(COMPILER_FOR_BUILD), and associated libraries,
+2011-04-06 Joseph Myers <joseph@codesourcery.com>
+
+ * c-target-def.h: New file.
+ * c-target.def: New file.
+ * c-target.h: New file.
+ * c-common.c (targetcm): Don't define here.
+ * c-common.h (default_handle_c_option): Declare.
+ * c-format.c: Include c-target.h instead of target.h.
+ * c-opts.c: Include c-target.h instead of target.h. Explicitly
+ include tm.h.
+ (default_handle_c_option): Move from targhooks.c.
+
2011-03-29 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/48248
}
}
-#ifndef TARGET_HAS_TARGETCM
-struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
-#endif
-
/* Warn for division by zero according to the value of DIVISOR. LOC
is the location of the division operator. */
extern bool attribute_takes_identifier_p (const_tree);
extern bool c_common_handle_option (size_t, const char *, int, int, location_t,
const struct cl_option_handlers *);
+extern bool default_handle_c_option (size_t, const char *, int);
extern tree c_common_type_for_mode (enum machine_mode, int);
extern tree c_common_type_for_size (unsigned int, int);
extern tree c_common_fixed_point_type_for_size (unsigned int, unsigned int,
/* Check calls to formatted I/O functions (-Wformat).
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GCC.
#include "langhooks.h"
#include "c-format.h"
#include "alloc-pool.h"
-#include "target.h"
+#include "c-target.h"
\f
/* Set format warning options according to a -Wformat=n option. */
#include "opts.h"
#include "options.h"
#include "mkdeps.h"
-#include "target.h" /* For gcc_targetcm. */
+#include "c-target.h"
+#include "tm.h" /* For BYTES_BIG_ENDIAN,
+ DOLLARS_IN_IDENTIFIERS,
+ STDC_0_IN_SYSTEM_HEADERS,
+ TARGET_FLT_EVAL_METHOD_NON_DEFAULT and
+ TARGET_OPTF. */
#include "tm_p.h" /* For C_COMMON_OVERRIDE_OPTIONS. */
#ifndef DOLLARS_IN_IDENTIFIERS
return result;
}
+/* Default implementation of TARGET_HANDLE_C_OPTION. */
+
+bool
+default_handle_c_option (size_t code ATTRIBUTE_UNUSED,
+ const char *arg ATTRIBUTE_UNUSED,
+ int value ATTRIBUTE_UNUSED)
+{
+ return false;
+}
+
/* Post-switch processing. */
bool
c_common_post_options (const char **pfilename)
--- /dev/null
+/* Default initializers for C-family target hooks.
+ Copyright (C) 2011
+ Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+#include "c-family/c-target-hooks-def.h"
+#include "tree.h"
+#include "c-family/c-common.h"
+#include "hooks.h"
--- /dev/null
+/* Target hook definitions for C-family front ends.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ 2011
+ Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+/* See target-hooks-macros.h for details of macros that should be
+ provided by the including file, and how to use them here. */
+#include "target-hooks-macros.h"
+
+#undef HOOK_TYPE
+#define HOOK_TYPE "C Target Hook"
+
+HOOK_VECTOR (TARGETCM_INITIALIZER, gcc_targetcm)
+
+#undef HOOK_PREFIX
+#define HOOK_PREFIX "TARGET_"
+
+/* Handle target switch CODE (an OPT_* value). ARG is the argument
+ passed to the switch; it is NULL if no argument was. VALUE is the
+ value of ARG if CODE specifies a UInteger option, otherwise it is
+ 1 if the positive form of the switch was used and 0 if the negative
+ form was. Return true if the switch was valid. */
+DEFHOOK
+(handle_c_option,
+ "",
+ bool, (size_t code, const char *arg, int value),
+ default_handle_c_option)
+
+/* Targets may provide a string object type that can be used within
+ and between C, C++, and Objective-C dialects. */
+
+DEFHOOK
+(objc_construct_string_object,
+ "Targets may provide a string object type that can be used within\
+ and between C, C++ and their respective Objective-C dialects.\
+ A string object might, for example, embed encoding and length information.\
+ These objects are considered opaque to the compiler and handled as references.\
+ An ideal implementation makes the composition of the string object\
+ match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep),\
+ allowing efficient interworking between C-only and Objective-C code.\
+ If a target implements string objects then this hook should return a\
+ reference to such an object constructed from the normal `C' string\
+ representation provided in @var{string}.\
+ At present, the hook is used by Objective-C only, to obtain a\
+ common-format string object when the target provides one.",
+ tree, (tree string),
+ NULL)
+
+DEFHOOK
+(string_object_ref_type_p,
+ "If a target implements string objects then this hook should return\
+ @code{true} if @var{stringref} is a valid reference to such an object.",
+ bool, (const_tree stringref),
+ hook_bool_const_tree_false)
+
+DEFHOOK
+(check_string_object_format_arg,
+ "If a target implements string objects then this hook should should\
+ provide a facility to check the function arguments in @var{args_list}\
+ against the format specifiers in @var{format_arg} where the type of\
+ @var{format_arg} is one recognized as a valid string reference type.",
+ void, (tree format_arg, tree args_list),
+ NULL)
+
+HOOK_VECTOR_END (C90_EMPTY_HACK)
--- /dev/null
+/* Data structure definitions for target-specific C-family behavior.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ 2011
+ Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>.
+
+ In other words, you are welcome to use, share and improve this program.
+ You are forbidden to forbid anyone else to use, share and improve
+ what you give them. Help stamp out software-hoarding! */
+
+#ifndef GCC_C_TARGET_H
+#define GCC_C_TARGET_H
+
+#define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME;
+#define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (* NAME) PARAMS;
+#define DEFHOOK_UNDOC DEFHOOK
+#define HOOKSTRUCT(FRAGMENT) FRAGMENT
+
+#include "c-target.def"
+
+/* Each target can provide their own. */
+extern struct gcc_targetcm targetcm;
+
+#endif /* GCC_C_TARGET_H */
#
# gnu_ld Set to yes or no depending on whether the target
# system normally uses GNU ld.
+#
+# target_has_targetcm Set to yes or no depending on whether the target
+# has its own definition of targetcm.
out_file=
tmake_file=
c_target_objs=
cxx_target_objs=
fortran_target_objs=
+target_has_targetcm=no
tm_defines=
xm_defines=
# Set this to force installation and use of collect2.
c_target_objs="${c_target_objs} darwin-c.o"
cxx_target_objs="${cxx_target_objs} darwin-c.o"
fortran_target_objs="darwin-f.o"
+ target_has_targetcm=yes
extra_objs="darwin.o"
extra_gcc_objs="darwin-driver.o"
default_use_cxa_atexit=yes
tm_file="${tm_file} rs6000/option-defaults.h"
esac
+if [ "$target_has_targetcm" = "no" ]; then
+ c_target_objs="$c_target_objs default-c.o"
+ cxx_target_objs="$cxx_target_objs default-c.o"
+fi
+
# Support for --with-cpu and related options (and a few unrelated options,
# too).
case ${with_cpu} in
/* Darwin support needed only by C/C++ frontends.
- Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2010
+ Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2010, 2011
Free Software Foundation, Inc.
Contributed by Apple Computer Inc.
#include "tm_p.h"
#include "cppdefault.h"
#include "prefix.h"
-#include "target.h"
-#include "target-def.h"
+#include "c-family/c-target.h"
+#include "c-family/c-target-def.h"
/* Pragmas. */
return true;
}
-#undef TARGET_HANDLE_C_OPTION
-#define TARGET_HANDLE_C_OPTION handle_c_option
-
-struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
-
/* Allow ObjC* access to CFStrings. */
-tree
+static tree
darwin_objc_construct_string (tree str)
{
if (!darwin_constant_cfstrings)
/* The string ref type is created as CFStringRef by <CFBase.h> therefore, we
must match for it explicitly, since it's outside the gcc code. */
-bool
+static bool
darwin_cfstring_ref_p (const_tree strp)
{
tree tn;
}
/* At present the behavior of this is undefined and it does nothing. */
-void
+static void
darwin_check_cfstring_format_arg (tree ARG_UNUSED (format_arg),
tree ARG_UNUSED (args_list))
{
NULL, NULL
}
};
+
+#undef TARGET_HANDLE_C_OPTION
+#define TARGET_HANDLE_C_OPTION handle_c_option
+
+#undef TARGET_OBJC_CONSTRUCT_STRING_OBJECT
+#define TARGET_OBJC_CONSTRUCT_STRING_OBJECT darwin_objc_construct_string
+
+#undef TARGET_STRING_OBJECT_REF_TYPE_P
+#define TARGET_STRING_OBJECT_REF_TYPE_P darwin_cfstring_ref_p
+
+#undef TARGET_CHECK_STRING_OBJECT_FORMAT_ARG
+#define TARGET_CHECK_STRING_OBJECT_FORMAT_ARG darwin_check_cfstring_format_arg
+
+struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
/* Prototypes.
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2010, 2011
Free Software Foundation, Inc.
This file is part of GCC.
extern tree darwin_init_cfstring_builtins (unsigned);
extern tree darwin_fold_builtin (tree, int, tree *, bool);
-extern tree darwin_objc_construct_string (tree);
extern bool darwin_cfstring_p (tree);
-extern bool darwin_cfstring_ref_p (const_tree);
-extern void darwin_check_cfstring_format_arg (tree, tree);
extern tree darwin_build_constant_cfstring (tree);
extern void darwin_enter_string_into_cfstring_table (tree);
/* We have target-specific builtins. */
#define TARGET_FOLD_BUILTIN darwin_fold_builtin
-#define TARGET_OBJC_CONSTRUCT_STRING_OBJECT \
- darwin_objc_construct_string
-
-#define TARGET_STRING_OBJECT_REF_TYPE_P \
- darwin_cfstring_ref_p
-
#define TARGET_N_FORMAT_TYPES 1
#define TARGET_FORMAT_TYPES darwin_additional_format_types
-#define TARGET_CHECK_STRING_OBJECT_FORMAT_ARG \
- darwin_check_cfstring_format_arg
-
-#define TARGET_HAS_TARGETCM 1
-
#ifndef USED_FOR_TARGET
extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **);
#define GCC_DRIVER_HOST_INITIALIZATION \
--- /dev/null
+/* Default C-family target hooks initializer.
+ Copyright (C) 2011
+ Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "c-family/c-target.h"
+#include "c-family/c-target-def.h"
+
+/* Do not include tm.h or tm_p.h here; if it is useful for a target to
+ define some macros for the initializer in a header without defining
+ targetcm itself (for example, because of interactions with some
+ hooks depending on the target OS and others on the target
+ architecture), create a separate tm_c.h for only the relevant
+ definitions. */
+
+struct gcc_targetcm targetcm = TARGETCM_INITIALIZER;
-# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
# Free Software Foundation, Inc.
#
# This file is part of GCC.
darwin-c.o: $(srcdir)/config/darwin-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(CPPLIB_H) $(TREE_H) $(C_PRAGMA_H) $(TM_P_H) \
- incpath.h flags.h $(C_COMMON_H)
+ incpath.h flags.h $(C_COMMON_H) $(C_TARGET_H) $(C_TARGET_DEF_H)
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(srcdir)/config/darwin-c.c $(PREPROCESSOR_DEFINES)
from being defined in the @file{.h} file to being part of the
@code{targetm} structure.
+Similarly, there is a @code{targetcm} variable for hooks that are
+specific to front ends for C-family languages, documented as ``C
+Target Hook''. This is declared in @file{c-family/c-target.h}, the
+the initializer @code{TARGETCM_INITIALIZER} in
+@file{c-family/c-target-def.h}. If targets initialize @code{targetcm}
+themselves, they should set @code{target_has_targetcm=yes} in
+@file{config.gcc}; otherwise a default definition is used.
+
@node Driver
@section Controlling the Compilation Driver, @file{gcc}
@cindex driver
via attributes).
@end deftypefn
-@deftypefn {Target Hook} bool TARGET_HANDLE_C_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value})
+@deftypefn {C Target Hook} bool TARGET_HANDLE_C_OPTION (size_t @var{code}, const char *@var{arg}, int @var{value})
This target hook is called whenever the user specifies one of the
target-specific C language family options described by the @file{.opt}
definition files(@pxref{Options}). It has the opportunity to do some
should use @code{TARGET_HANDLE_C_OPTION} instead.
@end deftypefn
-@deftypefn {Target Hook} tree TARGET_OBJC_CONSTRUCT_STRING_OBJECT (tree @var{string})
+@deftypefn {C Target Hook} tree TARGET_OBJC_CONSTRUCT_STRING_OBJECT (tree @var{string})
Targets may provide a string object type that can be used within and between C, C++ and their respective Objective-C dialects. A string object might, for example, embed encoding and length information. These objects are considered opaque to the compiler and handled as references. An ideal implementation makes the composition of the string object match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep), allowing efficient interworking between C-only and Objective-C code. If a target implements string objects then this hook should return a reference to such an object constructed from the normal `C' string representation provided in @var{string}. At present, the hook is used by Objective-C only, to obtain a common-format string object when the target provides one.
@end deftypefn
-@deftypefn {Target Hook} bool TARGET_STRING_OBJECT_REF_TYPE_P (const_tree @var{stringref})
+@deftypefn {C Target Hook} bool TARGET_STRING_OBJECT_REF_TYPE_P (const_tree @var{stringref})
If a target implements string objects then this hook should return @code{true} if @var{stringref} is a valid reference to such an object.
@end deftypefn
-@deftypefn {Target Hook} void TARGET_CHECK_STRING_OBJECT_FORMAT_ARG (tree @var{format_arg}, tree @var{args_list})
+@deftypefn {C Target Hook} void TARGET_CHECK_STRING_OBJECT_FORMAT_ARG (tree @var{format_arg}, tree @var{args_list})
If a target implements string objects then this hook should should provide a facility to check the function arguments in @var{args_list} against the format specifiers in @var{format_arg} where the type of @var{format_arg} is one recognized as a valid string reference type.
@end deftypefn
from being defined in the @file{.h} file to being part of the
@code{targetm} structure.
+Similarly, there is a @code{targetcm} variable for hooks that are
+specific to front ends for C-family languages, documented as ``C
+Target Hook''. This is declared in @file{c-family/c-target.h}, the
+the initializer @code{TARGETCM_INITIALIZER} in
+@file{c-family/c-target-def.h}. If targets initialize @code{targetcm}
+themselves, they should set @code{target_has_targetcm=yes} in
+@file{config.gcc}; otherwise a default definition is used.
+
@node Driver
@section Controlling the Compilation Driver, @file{gcc}
@cindex driver
/* Process target.def to create initialization macros definition in
target-hooks-def.h and documentation in target-hooks.texi.
- Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GCC.
#include "hashtab.h"
#include "errors.h"
-struct hook_desc { const char *doc, *type, *name, *param, *init; };
+struct hook_desc { const char *doc, *type, *name, *param, *init, *docname; };
static struct hook_desc hook_array[] = {
-#define HOOK_VECTOR_1(NAME, FRAGMENT) \
- { 0, 0, #NAME, 0, 0 },
+#define HOOK_VECTOR_1(NAME, FRAGMENT) \
+ { 0, 0, #NAME, 0, 0, HOOK_TYPE },
#define DEFHOOKPOD(NAME, DOC, TYPE, INIT) \
- { DOC, #TYPE, HOOK_PREFIX #NAME, 0, #INIT },
+ { DOC, #TYPE, HOOK_PREFIX #NAME, 0, #INIT, HOOK_TYPE },
#define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) \
- { DOC, #TYPE, HOOK_PREFIX #NAME, #PARAMS, #INIT },
+ { DOC, #TYPE, HOOK_PREFIX #NAME, #PARAMS, #INIT, HOOK_TYPE },
#define DEFHOOK_UNDOC(NAME, DOC, TYPE, PARAMS, INIT) \
- { "*", #TYPE, HOOK_PREFIX #NAME, #PARAMS, #INIT },
+ { "*", #TYPE, HOOK_PREFIX #NAME, #PARAMS, #INIT, HOOK_TYPE },
#include "target.def"
+#include "c-family/c-target.def"
#undef DEFHOOK
};
/* Print header. Function-valued hooks have a parameter list,
unlike POD-valued ones. */
deftype = hook_array[i].param ? "deftypefn" : "deftypevr";
- printf ("@%s {Target Hook} ", deftype);
+ printf ("@%s {%s} ", deftype, hook_array[i].docname);
if (strchr (hook_array[i].type, ' '))
printf ("{%s}", hook_array[i].type);
else
{
char *namex = upstrdup (hook_array[j].name);
- printf ("\n@%sx {Target Hook} {%s} %s",
- deftype, hook_array[j].type, namex);
+ printf ("\n@%sx {%s} {%s} %s",
+ deftype, hook_array[j].docname,
+ hook_array[j].type, namex);
}
if (hook_array[i].doc[0])
{
/* Emit #defines to stdout (this will be redirected to generate
target-hook-def.h) which set target hooks initializer macros
- to their default values. */
+ to their default values. These should only be emitted for hooks
+ whose type is given by DOCNAME. */
static void
-emit_init_macros (void)
+emit_init_macros (const char *docname)
{
int i;
const int MAX_NEST = 2;
{
char *name = upstrdup (hook_array[i].name);
+ if (strcmp (hook_array[i].docname, docname) != 0)
+ continue;
+
if (!hook_array[i].type)
{
if (*name)
int
main (int argc, char **argv)
{
- if (argc >= 2)
- emit_documentation (argv[1]);
+ if (argc >= 3)
+ emit_documentation (argv[2]);
else
- emit_init_macros ();
+ emit_init_macros (argv[1]);
return 0;
}
+2011-04-06 Joseph Myers <joseph@codesourcery.com>
+
+ * objc-act.c: Include c-target.h instead of target.h.
+ * Make-lang.in (objc/objc-act.o): Update dependencies.
+
2011-03-06 Joseph Myers <joseph@codesourcery.com>
* lang-specs.h: Match -save-temps* instead of -save-temps.
objc/objc-act.o : objc/objc-act.c $(START_HDRS) $(GGC_H) \
$(DIAGNOSTIC_CORE_H) toplev.h $(FLAGS_H) input.h $(FUNCTION_H) output.h debug.h \
$(LANGHOOKS_DEF_H) $(HASHTAB_H) $(C_PRAGMA_H) gt-objc-objc-act.h $(OBSTACK_H) \
- $(GIMPLE_H) objc/objc-runtime-shared-support.h objc/objc-runtime-hooks.h
+ $(GIMPLE_H) objc/objc-runtime-shared-support.h objc/objc-runtime-hooks.h \
+ $(C_TARGET_H)
objc.srcextra:
#include "toplev.h"
#include "ggc.h"
#include "debug.h"
-#include "target.h"
+#include "c-family/c-target.h"
#include "diagnostic-core.h"
#include "intl.h"
#include "cgraph.h"
FUNCTION_ARG_BOUNDARY MUST_USE_SJLJ_EXCEPTIONS US_SOFTWARE_GOFAST \
USING_SVR4_H SVR4_ASM_SPEC FUNCTION_ARG FUNCTION_ARG_ADVANCE \
FUNCTION_INCOMING_ARG IRA_COVER_CLASSES TARGET_VERSION \
- MACHINE_TYPE
+ MACHINE_TYPE TARGET_HAS_TARGETCM
/* Hooks that are no longer used. */
#pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \
--- /dev/null
+/* Common macros for target hook definitions.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ 2011
+ Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+/* The following macros should be provided by the including file:
+
+ DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT): Define a function-valued hook.
+ DEFHOOKPOD(DOC, TYPE, NAME, INIT): Define a piece-of-data 'hook'. */
+
+/* Defaults for optional macros:
+ DEFHOOKPODX(NAME, TYPE, INIT): Like DEFHOOKPOD, but share documentation
+ with the previous 'hook'. */
+#ifndef DEFHOOKPODX
+#define DEFHOOKPODX(NAME, TYPE, INIT) DEFHOOKPOD (NAME, 0, TYPE, INIT)
+#endif
+
+/* HOOKSTRUCT(FRAGMENT): Declarator fragments to encapsulate all the
+ members into a struct gcc_target, which in turn contains several
+ sub-structs. */
+#ifndef HOOKSTRUCT
+#define HOOKSTRUCT(FRAGMENT)
+#endif
+/* HOOK_VECTOR: Start a struct declaration, which then gets its own initializer.
+ HOOK_VECTOR_END: Close a struct declaration, providing a member declarator
+ name for nested use. */
+#ifndef HOOK_VECTOR_1
+#define HOOK_VECTOR_1(NAME, FRAGMENT) HOOKSTRUCT(FRAGMENT)
+#endif
+#define HOOK_VECTOR(INIT_NAME, SNAME) HOOK_VECTOR_1 (INIT_NAME, struct SNAME {)
+#define HOOK_VECTOR_END(DECL_NAME) HOOK_VECTOR_1(,} DECL_NAME ;)
+
+/* FIXME: For pre-existing hooks, we can't place the documentation in the
+ documentation field here till we get permission from the FSF to include
+ it in GPLed software - the target hook documentation is so far only
+ available under the GFDL. */
+
+/* A hook should generally be documented by a string in the DOC parameter,
+ which should contain texinfo markup. If the documentation is only available
+ under the GPL, but not under the GFDL, put it in a comment above the hook
+ definition. If the function declaration is available both under GPL and
+ GFDL, but the documentation is only available under the GFDL, put the
+ documentaton in tm.texi.in, heading with @hook <hookname> and closing
+ the paragraph with @end deftypefn / deftypevr as appropriate, and marking
+ the next autogenerated hook with @hook <hookname>.
+ In both these cases, leave the DOC string empty, i.e. "".
+ Sometimes, for some historic reason the function declaration
+ has to be documented differently
+ than what it is. In that case, use DEFHOOK_UNDOC to supress auto-generation
+ of documentation. DEFHOOK_UNDOC takes a DOC string which it ignores, so
+ you can put GPLed documentation string there if you have hopes that you
+ can clear the declaration & documentation for GFDL distribution later,
+ in which case you can then simply change the DEFHOOK_UNDOC to DEFHOOK
+ to turn on the autogeneration of the documentation.
+
+ A documentation string of "*" means not to emit any documentation at all,
+ and is mainly used internally for DEFHOOK_UNDOC. It should generally not
+ be used otherwise, but it has its use for exceptional cases where automatic
+ documentation is not wanted, and the real documentation is elsewere, like
+ for TARGET_ASM_{,UN}ALIGNED_INT_OP, which are hooks only for implementation
+ purposes; they refer to structs, the components of which are documented as
+ separate hooks TARGET_ASM_{,UN}ALIGNED_[HSDT]I_OP.
+ A DOC string of 0 is for internal use of DEFHOOKPODX and special table
+ entries only. */
+
+/* Empty macro arguments are undefined in C90, so use an empty macro
+ to close top-level hook structures. */
+#define C90_EMPTY_HACK
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
-/* The following macros should be provided by the including file:
-
- DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT): Define a function-valued hook.
- DEFHOOKPOD(DOC, TYPE, NAME, INIT): Define a piece-of-data 'hook'. */
-
-/* Defaults for optional macros:
- DEFHOOKPODX(NAME, TYPE, INIT): Like DEFHOOKPOD, but share documentation
- with the previous 'hook'. */
-#ifndef DEFHOOKPODX
-#define DEFHOOKPODX(NAME, TYPE, INIT) DEFHOOKPOD (NAME, 0, TYPE, INIT)
-#endif
-
-/* HOOKSTRUCT(FRAGMENT): Declarator fragments to encapsulate all the
- members into a struct gcc_target, which in turn contains several
- sub-structs. */
-#ifndef HOOKSTRUCT
-#define HOOKSTRUCT(FRAGMENT)
-#endif
-/* HOOK_VECTOR: Start a struct declaration, which then gets its own initializer.
- HOOK_VECTOR_END: Close a struct declaration, providing a member declarator
- name for nested use. */
-#ifndef HOOK_VECTOR_1
-#define HOOK_VECTOR_1(NAME, FRAGMENT) HOOKSTRUCT(FRAGMENT)
-#endif
-#define HOOK_VECTOR(INIT_NAME, SNAME) HOOK_VECTOR_1 (INIT_NAME, struct SNAME {)
-#define HOOK_VECTOR_END(DECL_NAME) HOOK_VECTOR_1(,} DECL_NAME ;)
+/* See target-hooks-macros.h for details of macros that should be
+ provided by the including file, and how to use them here. */
+#include "target-hooks-macros.h"
-HOOK_VECTOR (TARGET_INITIALIZER, gcc_target)
+#undef HOOK_TYPE
+#define HOOK_TYPE "Target Hook"
-/* FIXME: For pre-existing hooks, we can't place the documentation in the
- documentation field here till we get permission from the FSF to include
- it in GPLed software - the target hook documentation is so far only
- available under the GFDL. */
-
-/* A hook should generally be documented by a string in the DOC parameter,
- which should contain texinfo markup. If the documentation is only available
- under the GPL, but not under the GFDL, put it in a comment above the hook
- definition. If the function declaration is available both under GPL and
- GFDL, but the documentation is only available under the GFDL, put the
- documentaton in tm.texi.in, heading with @hook <hookname> and closing
- the paragraph with @end deftypefn / deftypevr as appropriate, and marking
- the next autogenerated hook with @hook <hookname>.
- In both these cases, leave the DOC string empty, i.e. "".
- Sometimes, for some historic reason the function declaration
- has to be documented differently
- than what it is. In that case, use DEFHOOK_UNDOC to supress auto-generation
- of documentation. DEFHOOK_UNDOC takes a DOC string which it ignores, so
- you can put GPLed documentation string there if you have hopes that you
- can clear the declaration & documentation for GFDL distribution later,
- in which case you can then simply change the DEFHOOK_UNDOC to DEFHOOK
- to turn on the autogeneration of the documentation.
-
- A documentation string of "*" means not to emit any documentation at all,
- and is mainly used internally for DEFHOOK_UNDOC. It should generally not
- be used otherwise, but it has its use for exceptional cases where automatic
- documentation is not wanted, and the real documentation is elsewere, like
- for TARGET_ASM_{,UN}ALIGNED_INT_OP, which are hooks only for implementation
- purposes; they refer to structs, the components of which are documented as
- separate hooks TARGET_ASM_{,UN}ALIGNED_[HSDT]I_OP.
- A DOC string of 0 is for internal use of DEFHOOKPODX and special table
- entries only. */
+HOOK_VECTOR (TARGET_INITIALIZER, gcc_target)
/* Functions that output assembler for the target. */
#define HOOK_PREFIX "TARGET_ASM_"
/* Leave the boolean fields at the end. */
-/* Empty macro arguments are undefined in C90, so use an empty macro. */
-#define C90_EMPTY_HACK
/* Close the 'struct gcc_target' definition. */
HOOK_VECTOR_END (C90_EMPTY_HACK)
-
-HOOK_VECTOR (TARGETCM_INITIALIZER, gcc_targetcm)
-
-/* Handle target switch CODE (an OPT_* value). ARG is the argument
- passed to the switch; it is NULL if no argument was. VALUE is the
- value of ARG if CODE specifies a UInteger option, otherwise it is
- 1 if the positive form of the switch was used and 0 if the negative
- form was. Return true if the switch was valid. */
-DEFHOOK
-(handle_c_option,
- "",
- bool, (size_t code, const char *arg, int value),
- default_handle_c_option)
-
-/* Targets may provide a string object type that can be used within
- and between C, C++, and Objective-C dialects. */
-
-DEFHOOK
-(objc_construct_string_object,
- "Targets may provide a string object type that can be used within\
- and between C, C++ and their respective Objective-C dialects.\
- A string object might, for example, embed encoding and length information.\
- These objects are considered opaque to the compiler and handled as references.\
- An ideal implementation makes the composition of the string object\
- match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep),\
- allowing efficient interworking between C-only and Objective-C code.\
- If a target implements string objects then this hook should return a\
- reference to such an object constructed from the normal `C' string\
- representation provided in @var{string}.\
- At present, the hook is used by Objective-C only, to obtain a\
- common-format string object when the target provides one.",
- tree, (tree string),
- NULL)
-
-DEFHOOK
-(string_object_ref_type_p,
- "If a target implements string objects then this hook should return\
- @code{true} if @var{stringref} is a valid reference to such an object.",
- bool, (const_tree stringref),
- hook_bool_const_tree_false)
-
-DEFHOOK
-(check_string_object_format_arg,
- "If a target implements string objects then this hook should should\
- provide a facility to check the function arguments in @var{args_list}\
- against the format specifiers in @var{format_arg} where the type of\
- @var{format_arg} is one recognized as a valid string reference type.",
- void, (tree format_arg, tree args_list),
- NULL)
-
-HOOK_VECTOR_END (C90_EMPTY_HACK)
extern struct gcc_target targetm;
-/* Each target can provide their own. */
-extern struct gcc_targetcm targetcm;
-
#endif /* GCC_TARGET_H */
return rclass;
}
-bool
-default_handle_c_option (size_t code ATTRIBUTE_UNUSED,
- const char *arg ATTRIBUTE_UNUSED,
- int value ATTRIBUTE_UNUSED)
-{
- return false;
-}
-
/* By default, if flag_pic is true, then neither local nor global relocs
should be placed in readonly memory. */
secondary_reload_info *);
extern void default_target_option_override (void);
extern void hook_void_bitmap (bitmap);
-extern bool default_handle_c_option (size_t, const char *, int);
extern int default_reloc_rw_mask (void);
extern tree default_mangle_decl_assembler_name (tree, tree);
extern tree default_emutls_var_fields (tree, tree *);