summaryrefslogtreecommitdiff
path: root/gcc/config/rs6000/rs6000.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/config/rs6000/rs6000.c')
-rw-r--r--gcc/config/rs6000/rs6000.c72
1 files changed, 35 insertions, 37 deletions
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 8b35a0416d1..eb9f0c36d95 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -1174,7 +1174,7 @@ rtl_opt_pass *make_pass_analyze_swaps (gcc::context*);
/* Hash table stuff for keeping track of TOC entries. */
-struct GTY(()) toc_hash_struct
+struct GTY((for_user)) toc_hash_struct
{
/* `key' will satisfy CONSTANT_P; in fact, it will satisfy
ASM_OUTPUT_SPECIAL_POOL_ENTRY_P. */
@@ -1183,18 +1183,30 @@ struct GTY(()) toc_hash_struct
int labelno;
};
-static GTY ((param_is (struct toc_hash_struct))) htab_t toc_hash_table;
+struct toc_hasher : ggc_hasher<toc_hash_struct *>
+{
+ static hashval_t hash (toc_hash_struct *);
+ static bool equal (toc_hash_struct *, toc_hash_struct *);
+};
+
+static GTY (()) hash_table<toc_hasher> *toc_hash_table;
/* Hash table to keep track of the argument types for builtin functions. */
-struct GTY(()) builtin_hash_struct
+struct GTY((for_user)) builtin_hash_struct
{
tree type;
enum machine_mode mode[4]; /* return value + 3 arguments. */
unsigned char uns_p[4]; /* and whether the types are unsigned. */
};
-static GTY ((param_is (struct builtin_hash_struct))) htab_t builtin_hash_table;
+struct builtin_hasher : ggc_hasher<builtin_hash_struct *>
+{
+ static hashval_t hash (builtin_hash_struct *);
+ static bool equal (builtin_hash_struct *, builtin_hash_struct *);
+};
+
+static GTY (()) hash_table<builtin_hasher> *builtin_hash_table;
/* Default register names. */
@@ -15113,13 +15125,11 @@ htm_init_builtins (void)
/* Hash function for builtin functions with up to 3 arguments and a return
type. */
-static unsigned
-builtin_hash_function (const void *hash_entry)
+hashval_t
+builtin_hasher::hash (builtin_hash_struct *bh)
{
unsigned ret = 0;
int i;
- const struct builtin_hash_struct *bh =
- (const struct builtin_hash_struct *) hash_entry;
for (i = 0; i < 4; i++)
{
@@ -15131,12 +15141,9 @@ builtin_hash_function (const void *hash_entry)
}
/* Compare builtin hash entries H1 and H2 for equivalence. */
-static int
-builtin_hash_eq (const void *h1, const void *h2)
+bool
+builtin_hasher::equal (builtin_hash_struct *p1, builtin_hash_struct *p2)
{
- const struct builtin_hash_struct *p1 = (const struct builtin_hash_struct *) h1;
- const struct builtin_hash_struct *p2 = (const struct builtin_hash_struct *) h2;
-
return ((p1->mode[0] == p2->mode[0])
&& (p1->mode[1] == p2->mode[1])
&& (p1->mode[2] == p2->mode[2])
@@ -15157,7 +15164,6 @@ builtin_function_type (enum machine_mode mode_ret, enum machine_mode mode_arg0,
{
struct builtin_hash_struct h;
struct builtin_hash_struct *h2;
- void **found;
int num_args = 3;
int i;
tree ret_type = NULL_TREE;
@@ -15165,8 +15171,7 @@ builtin_function_type (enum machine_mode mode_ret, enum machine_mode mode_arg0,
/* Create builtin_hash_table. */
if (builtin_hash_table == NULL)
- builtin_hash_table = htab_create_ggc (1500, builtin_hash_function,
- builtin_hash_eq, NULL);
+ builtin_hash_table = hash_table<builtin_hasher>::create_ggc (1500);
h.type = NULL_TREE;
h.mode[0] = mode_ret;
@@ -15322,18 +15327,18 @@ builtin_function_type (enum machine_mode mode_ret, enum machine_mode mode_arg0,
GET_MODE_NAME (m));
}
- found = htab_find_slot (builtin_hash_table, &h, INSERT);
+ builtin_hash_struct **found = builtin_hash_table->find_slot (&h, INSERT);
if (*found == NULL)
{
h2 = ggc_alloc<builtin_hash_struct> ();
*h2 = h;
- *found = (void *)h2;
+ *found = h2;
h2->type = build_function_type_list (ret_type, arg_type[0], arg_type[1],
arg_type[2], NULL_TREE);
}
- return ((struct builtin_hash_struct *)(*found))->type;
+ return (*found)->type;
}
static void
@@ -25561,24 +25566,21 @@ rs6000_hash_constant (rtx k)
return result;
}
-static unsigned
-toc_hash_function (const void *hash_entry)
+hashval_t
+toc_hasher::hash (toc_hash_struct *thc)
{
- const struct toc_hash_struct *thc =
- (const struct toc_hash_struct *) hash_entry;
return rs6000_hash_constant (thc->key) ^ thc->key_mode;
}
/* Compare H1 and H2 for equivalence. */
-static int
-toc_hash_eq (const void *h1, const void *h2)
+bool
+toc_hasher::equal (toc_hash_struct *h1, toc_hash_struct *h2)
{
- rtx r1 = ((const struct toc_hash_struct *) h1)->key;
- rtx r2 = ((const struct toc_hash_struct *) h2)->key;
+ rtx r1 = h1->key;
+ rtx r2 = h2->key;
- if (((const struct toc_hash_struct *) h1)->key_mode
- != ((const struct toc_hash_struct *) h2)->key_mode)
+ if (h1->key_mode != h2->key_mode)
return 0;
return rtx_equal_p (r1, r2);
@@ -25665,20 +25667,18 @@ output_toc (FILE *file, rtx x, int labelno, enum machine_mode mode)
if (TARGET_TOC && GET_CODE (x) != LABEL_REF)
{
struct toc_hash_struct *h;
- void * * found;
/* Create toc_hash_table. This can't be done at TARGET_OPTION_OVERRIDE
time because GGC is not initialized at that point. */
if (toc_hash_table == NULL)
- toc_hash_table = htab_create_ggc (1021, toc_hash_function,
- toc_hash_eq, NULL);
+ toc_hash_table = hash_table<toc_hasher>::create_ggc (1021);
h = ggc_alloc<toc_hash_struct> ();
h->key = x;
h->key_mode = mode;
h->labelno = labelno;
- found = htab_find_slot (toc_hash_table, h, INSERT);
+ toc_hash_struct **found = toc_hash_table->find_slot (h, INSERT);
if (*found == NULL)
*found = h;
else /* This is indeed a duplicate.
@@ -25688,8 +25688,7 @@ output_toc (FILE *file, rtx x, int labelno, enum machine_mode mode)
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LC");
fprintf (file, "%d,", labelno);
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LC");
- fprintf (file, "%d\n", ((*(const struct toc_hash_struct **)
- found)->labelno));
+ fprintf (file, "%d\n", ((*found)->labelno));
#ifdef HAVE_AS_TLS
if (TARGET_XCOFF && GET_CODE (x) == SYMBOL_REF
@@ -25700,8 +25699,7 @@ output_toc (FILE *file, rtx x, int labelno, enum machine_mode mode)
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LCM");
fprintf (file, "%d,", labelno);
ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "LCM");
- fprintf (file, "%d\n", ((*(const struct toc_hash_struct **)
- found)->labelno));
+ fprintf (file, "%d\n", ((*found)->labelno));
}
#endif
return;