===================================================================
@@ -969,7 +969,7 @@ GCC_PLUGIN_H = gcc-plugin.h highlev-plug
$(HASHTAB_H)
PLUGIN_H = plugin.h $(GCC_PLUGIN_H)
PLUGIN_VERSION_H = plugin-version.h configargs.h
-LIBFUNCS_H = libfuncs.h
+LIBFUNCS_H = libfuncs.h $(HASHTAB_H)
#
# Now figure out from those variables how to compile and link.
@@ -3478,7 +3478,8 @@ lower-subreg.o : lower-subreg.c $(CONFIG
$(EXPR_H) $(EXCEPT_H) $(REGS_H) $(TREE_PASS_H) $(DF_H)
target-globals.o : target-globals.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) insn-config.h $(MACHMODE_H) $(GGC_H) $(TOPLEV_H) target-globals.h \
- $(FLAGS_H) $(REGS_H) $(RTL_H) reload.h expmed.h $(EXPR_H) $(OPTABS_H)
+ $(FLAGS_H) $(REGS_H) $(RTL_H) reload.h expmed.h $(EXPR_H) $(OPTABS_H) \
+ $(LIBFUNCS_H)
$(out_object_file): $(out_file) $(CONFIG_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) $(REGS_H) hard-reg-set.h insn-config.h conditions.h \
===================================================================
@@ -20,6 +20,8 @@ the Free Software Foundation; either ver
#ifndef GCC_LIBFUNCS_H
#define GCC_LIBFUNCS_H
+#include "hashtab.h"
+
/* Enumeration of indexes into libfunc_table. */
enum libfunc_index
{
@@ -45,9 +47,34 @@ enum libfunc_index
LTI_MAX
};
-/* SYMBOL_REF rtx's for the library functions that are called
- implicitly and not via optabs. */
-extern GTY(()) rtx libfunc_table[LTI_MAX];
+/* Information about an optab-related libfunc. We use the same hashtable
+ for normal optabs and conversion optabs. In the first case mode2
+ is unused. */
+struct GTY(()) libfunc_entry {
+ size_t optab;
+ enum machine_mode mode1, mode2;
+ rtx libfunc;
+};
+
+/* Target-dependent globals. */
+struct GTY(()) target_libfuncs {
+ /* SYMBOL_REF rtx's for the library functions that are called
+ implicitly and not via optabs. */
+ rtx x_libfunc_table[LTI_MAX];
+
+ /* Hash table used to convert declarations into nodes. */
+ htab_t GTY((param_is (struct libfunc_entry))) x_libfunc_hash;
+};
+
+extern GTY(()) struct target_libfuncs default_target_libfuncs;
+#if SWITCHABLE_TARGET
+extern struct target_libfuncs *this_target_libfuncs;
+#else
+#define this_target_libfuncs (&default_target_libfuncs)
+#endif
+
+#define libfunc_table \
+ (this_target_libfuncs->x_libfunc_table)
/* Accessor macros for libfunc_table. */
===================================================================
@@ -45,11 +45,14 @@ Software Foundation; either version 3, o
#include "target.h"
struct target_optabs default_target_optabs;
+struct target_libfuncs default_target_libfuncs;
#if SWITCHABLE_TARGET
struct target_optabs *this_target_optabs;
+struct target_libfuncs *this_target_libfuncs;
#endif
-rtx libfunc_table[LTI_MAX];
+#define libfunc_hash \
+ (this_target_libfuncs->x_libfunc_hash)
/* Contains the optab used for each rtx code. */
optab code_to_optab[NUM_RTX_CODE + 1];
@@ -68,19 +71,7 @@ #define DECIMAL_PREFIX "bid_"
#define DECIMAL_PREFIX "dpd_"
#endif
-
-/* Info about libfunc. We use same hashtable for normal optabs and conversion
- optab. In the first case mode2 is unused. */
-struct GTY(()) libfunc_entry {
- size_t optab;
- enum machine_mode mode1, mode2;
- rtx libfunc;
-};
-
-/* Hash table used to convert declarations into nodes. */
-static GTY((param_is (struct libfunc_entry))) htab_t libfunc_hash;
-
-/* Used for attribute_hash. */
+/* Used for libfunc_hash. */
static hashval_t
hash_libfunc (const void *p)
@@ -91,7 +82,7 @@ hash_libfunc (const void *p)
^ e->optab);
}
-/* Used for optab_hash. */
+/* Used for libfunc_hash. */
static int
eq_libfunc (const void *p, const void *q)
@@ -6123,14 +6114,15 @@ set_conv_libfunc (convert_optab optable,
void
init_optabs (void)
{
- static bool reinit;
-
- libfunc_hash = htab_create_ggc (10, hash_libfunc, eq_libfunc, NULL);
-
- /* We statically initialize the insn_codes with the equivalent of
- CODE_FOR_nothing. Repeat the process if reinitialising. */
- if (reinit)
- init_insn_codes ();
+ if (libfunc_hash)
+ {
+ htab_empty (libfunc_hash);
+ /* We statically initialize the insn_codes with the equivalent of
+ CODE_FOR_nothing. Repeat the process if reinitialising. */
+ init_insn_codes ();
+ }
+ else
+ libfunc_hash = htab_create_ggc (10, hash_libfunc, eq_libfunc, NULL);
init_optab (add_optab, PLUS);
init_optabv (addv_optab, PLUS);
@@ -6571,8 +6563,6 @@ init_optabs (void)
/* Allow the target to add more libcalls or rename some, etc. */
targetm.init_libfuncs ();
-
- reinit = true;
}
/* Print information about the current contents of the optabs on
===================================================================
@@ -28,6 +28,7 @@ #define TARGET_GLOBALS_H 1
extern struct target_reload *this_target_reload;
extern struct target_expmed *this_target_expmed;
extern struct target_optabs *this_target_optabs;
+extern struct target_libfuncs *this_target_libfuncs;
struct GTY(()) target_globals {
struct target_flag_state *GTY((skip)) flag_state;
@@ -37,6 +38,7 @@ struct GTY(()) target_globals {
struct target_reload *GTY((skip)) reload;
struct target_expmed *GTY((skip)) expmed;
struct target_optabs *GTY((skip)) optabs;
+ struct target_libfuncs *libfuncs;
};
extern struct target_globals default_target_globals;
@@ -53,6 +55,7 @@ restore_target_globals (struct target_gl
this_target_reload = g->reload;
this_target_expmed = g->expmed;
this_target_optabs = g->optabs;
+ this_target_libfuncs = g->libfuncs;
}
#endif
===================================================================
@@ -34,6 +34,7 @@ Software Foundation; either version 3, o
#include "expmed.h"
#include "expr.h"
#include "optabs.h"
+#include "libfuncs.h"
#if SWITCHABLE_TARGET
struct target_globals default_target_globals = {
@@ -43,7 +44,8 @@ struct target_globals default_target_glo
&default_target_hard_regs,
&default_target_reload,
&default_target_expmed,
- &default_target_optabs
+ &default_target_optabs,
+ &default_target_libfuncs
};
struct target_globals *
@@ -59,6 +61,7 @@ save_target_globals (void)
g->reload = XCNEW (struct target_reload);
g->expmed = XCNEW (struct target_expmed);
g->optabs = XCNEW (struct target_optabs);
+ g->libfuncs = ggc_alloc_cleared_target_libfuncs ();
restore_target_globals (g);
target_reinit ();
return g;