aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <rdsandiford@googlemail.com>2011-12-22 21:28:40 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2011-12-22 21:28:40 +0000
commite32ea2d1b2616cba725adfa4a87b2977a40e55be (patch)
tree86c95c2ba1ad59a3914d1b821fdd7358f55e43ad
parentdcf3062542089393814c0dbda875ec6a30a6b0b0 (diff)
downloadgcc-e32ea2d1b2616cba725adfa4a87b2977a40e55be.zip
gcc-e32ea2d1b2616cba725adfa4a87b2977a40e55be.tar.gz
gcc-e32ea2d1b2616cba725adfa4a87b2977a40e55be.tar.bz2
tm.texi.in (TARGET_PREPARE_PCH_SAVE): New hook.
gcc/ * doc/tm.texi.in (TARGET_PREPARE_PCH_SAVE): New hook. * doc/tm.texi: Regenerate. * target.def (prepare_pch_save): New hook. * c-family/c-pch.c (c_common_write_pch): Call it. * config/mips/mips.c (was_mips16_pch_p): Delete. (mips_set_mips16_mode): Don't refer to was_mips16_pch_p. (mips_prepare_pch_save): New function. (TARGET_PREPARE_PCH_SAVE): Define. From-SVN: r182640
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/c-family/c-pch.c2
-rw-r--r--gcc/config/mips/mips.c43
-rw-r--r--gcc/doc/tm.texi7
-rw-r--r--gcc/doc/tm.texi.in2
-rw-r--r--gcc/target.def9
6 files changed, 64 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e01b24d..711e39a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2011-12-22 Richard Sandiford <rdsandiford@googlemail.com>
+
+ * doc/tm.texi.in (TARGET_PREPARE_PCH_SAVE): New hook.
+ * doc/tm.texi: Regenerate.
+ * target.def (prepare_pch_save): New hook.
+ * c-family/c-pch.c (c_common_write_pch): Call it.
+ * config/mips/mips.c (was_mips16_pch_p): Delete.
+ (mips_set_mips16_mode): Don't refer to was_mips16_pch_p.
+ (mips_prepare_pch_save): New function.
+ (TARGET_PREPARE_PCH_SAVE): Define.
+
2011-12-22 Aldy Hernandez <aldyh@redhat.com>
PR middle-end/51212
diff --git a/gcc/c-family/c-pch.c b/gcc/c-family/c-pch.c
index 7a289d6..8d34e09 100644
--- a/gcc/c-family/c-pch.c
+++ b/gcc/c-family/c-pch.c
@@ -180,6 +180,8 @@ c_common_write_pch (void)
timevar_push (TV_PCH_SAVE);
+ targetm.prepare_pch_save ();
+
(*debug_hooks->handle_pch) (1);
cpp_write_pch_deps (parse_in, pch_outfile);
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 3866c46..cf908f6 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -15208,14 +15208,8 @@ mips_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
}
/* The last argument passed to mips_set_mips16_mode, or negative if the
- function hasn't been called yet.
-
- There are two copies of this information. One is saved and restored
- by the PCH process while the other is specific to this compiler
- invocation. The information calculated by mips_set_mips16_mode
- is invalid unless the two variables are the same. */
+ function hasn't been called yet. */
static int was_mips16_p = -1;
-static GTY(()) int was_mips16_pch_p = -1;
/* Set up the target-dependent global state so that it matches the
current function's ISA mode. */
@@ -15223,8 +15217,7 @@ static GTY(()) int was_mips16_pch_p = -1;
static void
mips_set_mips16_mode (int mips16_p)
{
- if (mips16_p == was_mips16_p
- && mips16_p == was_mips16_pch_p)
+ if (mips16_p == was_mips16_p)
return;
/* Restore base settings of various flags. */
@@ -15321,7 +15314,6 @@ mips_set_mips16_mode (int mips16_p)
restore_target_globals (&default_target_globals);
was_mips16_p = mips16_p;
- was_mips16_pch_p = mips16_p;
}
/* Implement TARGET_SET_CURRENT_FUNCTION. Decide whether the current
@@ -16336,6 +16328,34 @@ mips_shift_truncation_mask (enum machine_mode mode)
return GET_MODE_BITSIZE (mode) - 1;
}
+/* Implement TARGET_PREPARE_PCH_SAVE. */
+
+static void
+mips_prepare_pch_save (void)
+{
+ /* We are called in a context where the current MIPS16 vs. non-MIPS16
+ setting should be irrelevant. The question then is: which setting
+ makes most sense at load time?
+
+ The PCH is loaded before the first token is read. We should never
+ have switched into MIPS16 mode by that point, and thus should not
+ have populated mips16_globals. Nor can we load the entire contents
+ of mips16_globals from the PCH file, because mips16_globals contains
+ a combination of GGC and non-GGC data.
+
+ There is therefore no point in trying save the GGC part of
+ mips16_globals to the PCH file, or to preserve MIPS16ness across
+ the PCH save and load. The loading compiler would not have access
+ to the non-GGC parts of mips16_globals (either from the PCH file,
+ or from a copy that the loading compiler generated itself) and would
+ have to call target_reinit anyway.
+
+ It therefore seems best to switch back to non-MIPS16 mode at
+ save time, and to ensure that mips16_globals remains null after
+ a PCH load. */
+ mips_set_mips16_mode (false);
+ mips16_globals = 0;
+}
/* Initialize the GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP
@@ -16555,6 +16575,9 @@ mips_shift_truncation_mask (enum machine_mode mode)
#undef TARGET_SHIFT_TRUNCATION_MASK
#define TARGET_SHIFT_TRUNCATION_MASK mips_shift_truncation_mask
+#undef TARGET_PREPARE_PCH_SAVE
+#define TARGET_PREPARE_PCH_SAVE mips_prepare_pch_save
+
struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-mips.h"
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index c98b93c..6d41cee 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -10079,6 +10079,13 @@ of @code{target_flags}. @var{pch_flags} specifies the value that
value is the same as for @code{TARGET_PCH_VALID_P}.
@end deftypefn
+@deftypefn {Target Hook} void TARGET_PREPARE_PCH_SAVE (void)
+Called before writing out a PCH file. If the target has some
+garbage-collected data that needs to be in a particular state on PCH loads,
+it can use this hook to enforce that state. Very few targets need
+to do anything here.
+@end deftypefn
+
@node C++ ABI
@section C++ ABI parameters
@cindex parameters, c++ abi
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index d5a7d39..396f244 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -9974,6 +9974,8 @@ of @code{target_flags}. @var{pch_flags} specifies the value that
value is the same as for @code{TARGET_PCH_VALID_P}.
@end deftypefn
+@hook TARGET_PREPARE_PCH_SAVE
+
@node C++ ABI
@section C++ ABI parameters
@cindex parameters, c++ abi
diff --git a/gcc/target.def b/gcc/target.def
index f5a5d54..b68673c 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -1819,6 +1819,15 @@ DEFHOOK
const char *, (const void *data, size_t sz),
default_pch_valid_p)
+DEFHOOK
+(prepare_pch_save,
+ "Called before writing out a PCH file. If the target has some\n\
+garbage-collected data that needs to be in a particular state on PCH loads,\n\
+it can use this hook to enforce that state. Very few targets need\n\
+to do anything here.",
+ void, (void),
+ hook_void_void)
+
/* 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. */