Commit 8d932be3 by Richard Sandiford Committed by Richard Sandiford

tm.texi (TARGET_GET_PCH_VALIDITY, [...]): Tweak the documentation to make it more future-proof.

	* doc/tm.texi (TARGET_GET_PCH_VALIDITY, TARGET_PCH_VALID_P): Tweak
	the documentation to make it more future-proof.
	(TARGET_CHECK_PCH_TARGET_FLAGS): Document this new hook.
	* target.h (gcc_target): Add check_pch_target_flags.
	* target-def.h (TARGET_CHECK_PCH_TARGET_FLAGS): New macro.
	(TARGET_INITIALIZER): Include it.
	* toplev.c (default_pch_valid_p): Use targetm.check_pch_target_flags.
	* config/sh/sh.h (sh_pch_valid_p): Delete.
	* config/sh/sh.c (TARGET_PCH_VALID_P, sh_pch_valid_p): Delete.
	(sh_check_pch_target_flags): New function.
	(TARGET_CHECK_PCH_TARGET_FLAGS): Override default.

From-SVN: r100392
parent 4ea73bfa
2005-05-31 Richard Sandiford <rsandifo@redhat.com>
* doc/tm.texi (TARGET_GET_PCH_VALIDITY, TARGET_PCH_VALID_P): Tweak
the documentation to make it more future-proof.
(TARGET_CHECK_PCH_TARGET_FLAGS): Document this new hook.
* target.h (gcc_target): Add check_pch_target_flags.
* target-def.h (TARGET_CHECK_PCH_TARGET_FLAGS): New macro.
(TARGET_INITIALIZER): Include it.
* toplev.c (default_pch_valid_p): Use targetm.check_pch_target_flags.
* config/sh/sh.h (sh_pch_valid_p): Delete.
* config/sh/sh.c (TARGET_PCH_VALID_P, sh_pch_valid_p): Delete.
(sh_check_pch_target_flags): New function.
(TARGET_CHECK_PCH_TARGET_FLAGS): Override default.
2005-05-31 Richard Guenther <rguenth@gcc.gnu.org>
* fold-const.c (extract_array_ref): Handle more cases,
......
......@@ -228,6 +228,7 @@ static tree sh_handle_trap_exit_attribute (tree *, tree, tree, int, bool *);
static tree sh_handle_renesas_attribute (tree *, tree, tree, int, bool *);
static void sh_output_function_epilogue (FILE *, HOST_WIDE_INT);
static void sh_insert_attributes (tree, tree *);
static const char *sh_check_pch_target_flags (int);
static int sh_adjust_cost (rtx, rtx, rtx, int);
static int sh_issue_rate (void);
static int sh_dfa_new_cycle (FILE *, int, rtx, int, int, int *sort_p);
......@@ -467,8 +468,8 @@ static int hard_regs_intersect_p (HARD_REG_SET *, HARD_REG_SET *);
#undef TARGET_VECTOR_MODE_SUPPORTED_P
#define TARGET_VECTOR_MODE_SUPPORTED_P sh_vector_mode_supported_p
#undef TARGET_PCH_VALID_P
#define TARGET_PCH_VALID_P sh_pch_valid_p
#undef TARGET_CHECK_PCH_TARGET_FLAGS
#define TARGET_CHECK_PCH_TARGET_FLAGS sh_check_pch_target_flags
#undef TARGET_DWARF_CALLING_CONVENTION
#define TARGET_DWARF_CALLING_CONVENTION sh_dwarf_calling_convention
......@@ -7515,36 +7516,11 @@ sh_cfun_interrupt_handler_p (void)
!= NULL_TREE);
}
/* Like default_pch_valid_p, but only check certain target_flags. */
const char *
sh_pch_valid_p (const void *data_p, size_t len)
{
#ifdef TARGET_OPTIONS
/* ??? We have a copy of this in toplev.c, but it is static. */
static const struct
{
const char *const prefix;
const char **const variable;
const char *const description;
const char *const value;
}
target_options[] = TARGET_OPTIONS;
#endif
/* Implement TARGET_CHECK_PCH_TARGET_FLAGS. */
const char *data = (const char *)data_p;
const char *flag_that_differs = NULL;
size_t i;
int old_flags;
/* -fpic and -fpie also usually make a PCH invalid. */
if (data[0] != flag_pic)
return _("created and used with different settings of -fpic");
if (data[1] != flag_pie)
return _("created and used with different settings of -fpie");
data += 2;
/* Check target_flags. */
memcpy (&old_flags, data, sizeof (target_flags));
static const char *
sh_check_pch_target_flags (int old_flags)
{
if ((old_flags ^ target_flags) & (MASK_SH1 | MASK_SH2 | MASK_SH3
| MASK_SH_E | MASK_HARD_SH4
| MASK_FPU_SINGLE | MASK_SH4))
......@@ -7553,40 +7529,7 @@ sh_pch_valid_p (const void *data_p, size_t len)
return _("created and used with different ABIs");
if ((old_flags ^ target_flags) & MASK_LITTLE_ENDIAN)
return _("created and used with different endianness");
data += sizeof (target_flags);
len -= sizeof (target_flags);
/* Check string options. */
#ifdef TARGET_OPTIONS
for (i = 0; i < ARRAY_SIZE (target_options); i++)
{
const char *str = *target_options[i].variable;
size_t l;
if (! str)
str = "";
l = strlen (str) + 1;
if (len < l || memcmp (data, str, l) != 0)
{
flag_that_differs = target_options[i].prefix;
goto make_message;
}
data += l;
len -= l;
}
#endif
return NULL;
make_message:
{
char *r;
asprintf (&r, _("created and used with differing settings of '-m%s'"),
flag_that_differs);
if (r == NULL)
return _("out of memory");
return r;
}
}
/* Predicates used by the templates. */
......
......@@ -8668,24 +8668,32 @@ Default: empty.
@section Parameters for Precompiled Header Validity Checking
@cindex parameters, precompiled headers
@deftypefn {Target Hook} void * TARGET_GET_PCH_VALIDITY (size_t * @var{sz})
Define this hook if your target needs to check a different collection
of flags than the default, which is every flag defined by
@code{TARGET_SWITCHES} and @code{TARGET_OPTIONS}. It should return
some data which will be saved in the PCH file and presented to
@code{TARGET_PCH_VALID_P} later; it should set @code{SZ} to the size
of the data.
@end deftypefn
@deftypefn {Target Hook} const char * TARGET_PCH_VALID_P (const void * @var{data}, size_t @var{sz})
Define this hook if your target needs to check a different collection of
flags than the default, which is every flag defined by @code{TARGET_SWITCHES}
and @code{TARGET_OPTIONS}. It is given data which came from
@code{TARGET_GET_PCH_VALIDITY} (in this version of this compiler, so there
is no need for extensive validity checking). It returns @code{NULL} if
it is safe to load a PCH file with this data, or a suitable error message
if not. The error message will be presented to the user, so it should
be localized.
@deftypefn {Target Hook} void *TARGET_GET_PCH_VALIDITY (size_t *@var{sz})
This hook returns the data needed by @code{TARGET_PCH_VALID_P} and sets
@samp{*@var{sz}} to the size of the data in bytes.
@end deftypefn
@deftypefn {Target Hook} const char *TARGET_PCH_VALID_P (const void *@var{data}, size_t @var{sz})
This hook checks whether the options used to create a PCH file are
compatible with the current settings. It returns @code{NULL}
if so and a suitable error message if not. Error messages will
be presented to the user and must be localized using @samp{_(@var{msg})}.
@var{data} is the data that was returned by @code{TARGET_GET_PCH_VALIDITY}
when the PCH file was created and @var{sz} is the size of that data in bytes.
It's safe to assume that the data was created by the same version of the
compiler, so no format checking is needed.
The default definition of @code{default_pch_valid_p} should be
suitable for most targets.
@end deftypefn
@deftypefn {Target Hook} const char *TARGET_CHECK_PCH_TARGET_FLAGS (int @var{pch_flags})
If this hook is nonnull, the default implementation of
@code{TARGET_PCH_VALID_P} will use it to check for compatible values
of @code{target_flags}. @var{pch_flags} specifies the value that
@code{target_flags} had when the PCH file was created. The return
value is the same as for @code{TARGET_PCH_VALID_P}.
@end deftypefn
@node C++ ABI
......
......@@ -379,6 +379,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TARGET_GET_PCH_VALIDITY default_get_pch_validity
#define TARGET_PCH_VALID_P default_pch_valid_p
#define TARGET_CHECK_PCH_TARGET_FLAGS NULL
#define TARGET_DEFAULT_SHORT_ENUMS hook_bool_void_false
......@@ -551,6 +552,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
TARGET_GIMPLIFY_VA_ARG_EXPR, \
TARGET_GET_PCH_VALIDITY, \
TARGET_PCH_VALID_P, \
TARGET_CHECK_PCH_TARGET_FLAGS, \
TARGET_DEFAULT_SHORT_ENUMS, \
TARGET_BUILTIN_SETJMP_FRAME_VALUE, \
TARGET_MD_ASM_CLOBBERS, \
......
......@@ -485,6 +485,11 @@ struct gcc_target
void * (* get_pch_validity) (size_t *);
const char * (* pch_valid_p) (const void *, size_t);
/* If nonnull, this function checks whether a PCH file with the
given set of target flags can be used. It returns NULL if so,
otherwise it returns an error message. */
const char *(*check_pch_target_flags) (int);
/* True if the compiler should give an enum type only as many
bytes as it takes to represent the range of possible values of
that type. */
......
......@@ -1487,6 +1487,7 @@ default_pch_valid_p (const void *data_p, size_t len)
const char *data = (const char *)data_p;
const char *flag_that_differs = NULL;
size_t i;
int tf;
/* -fpic and -fpie also usually make a PCH invalid. */
if (data[0] != flag_pic)
......@@ -1496,11 +1497,15 @@ default_pch_valid_p (const void *data_p, size_t len)
data += 2;
/* Check target_flags. */
if (memcmp (data, &target_flags, sizeof (target_flags)) != 0)
memcpy (&tf, data, sizeof (target_flags));
if (targetm.check_pch_target_flags)
{
const char *r = targetm.check_pch_target_flags (tf);
if (r != NULL)
return r;
}
else if (tf != target_flags)
{
int tf;
memcpy (&tf, data, sizeof (target_flags));
#ifdef TARGET_SWITCHES
for (i = 0; i < ARRAY_SIZE (target_switches); i++)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment