]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/symtab.c
sh.c: Do not include algorithm.
[thirdparty/gcc.git] / gcc / symtab.c
index f23bd83f4698b91ec799542fa4488404e4e2edba..29839e676f003cdf406d6059282bc035e112e4a5 100644 (file)
@@ -26,8 +26,15 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "print-tree.h"
 #include "varasm.h"
+#include "hashtab.h"
+#include "hash-set.h"
+#include "vec.h"
+#include "machmode.h"
+#include "hard-reg-set.h"
+#include "input.h"
 #include "function.h"
 #include "emit-rtl.h"
+#include "predict.h"
 #include "basic-block.h"
 #include "tree-ssa-alias.h"
 #include "internal-fn.h"
@@ -36,7 +43,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple.h"
 #include "tree-inline.h"
 #include "langhooks.h"
-#include "hashtab.h"
+#include "hash-map.h"
+#include "plugin-api.h"
+#include "ipa-ref.h"
 #include "cgraph.h"
 #include "diagnostic.h"
 #include "timevar.h"
@@ -45,7 +54,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-utils.h"
 #include "calls.h"
 
-static const char *ipa_ref_use_name[] = {"read","write","addr","alias"};
+static const char *ipa_ref_use_name[] = {"read","write","addr","alias","chkp"};
 
 const char * const ld_plugin_symbol_resolution_names[]=
 {
@@ -83,15 +92,6 @@ symbol_table::decl_assembler_name_hash (const_tree asmname)
 }
 
 
-/* Returns a hash code for P.  */
-
-hashval_t
-symbol_table::hash_node_by_assembler_name (const void *p)
-{
-  const symtab_node *n = (const symtab_node *) p;
-  return (hashval_t) decl_assembler_name_hash (DECL_ASSEMBLER_NAME (n->decl));
-}
-
 /* Compare ASMNAME with the DECL_ASSEMBLER_NAME of DECL.  */
 
 bool
@@ -150,14 +150,6 @@ symbol_table::decl_assembler_name_equal (tree decl, const_tree asmname)
 
 /* Returns nonzero if P1 and P2 are equal.  */
 
-int
-symbol_table::eq_assembler_name (const void *p1, const void *p2)
-{
-  const symtab_node *n1 = (const symtab_node *) p1;
-  const_tree name = (const_tree)p2;
-  return (decl_assembler_name_equal (n1->decl, name));
-}
-
 /* Insert NODE to assembler name hash.  */
 
 void
@@ -170,19 +162,18 @@ symbol_table::insert_to_assembler_name_hash (symtab_node *node,
                       && !node->next_sharing_asm_name);
   if (assembler_name_hash)
     {
-      void **aslot;
+      symtab_node **aslot;
       cgraph_node *cnode;
       tree decl = node->decl;
 
       tree name = DECL_ASSEMBLER_NAME (node->decl);
 
-      aslot = htab_find_slot_with_hash (assembler_name_hash, name,
-                                       decl_assembler_name_hash (name),
-                                       INSERT);
+      hashval_t hash = decl_assembler_name_hash (name);
+      aslot = assembler_name_hash->find_slot_with_hash (name, hash, INSERT);
       gcc_assert (*aslot != node);
       node->next_sharing_asm_name = (symtab_node *)*aslot;
       if (*aslot != NULL)
-       ((symtab_node *)*aslot)->previous_sharing_asm_name = node;
+       (*aslot)->previous_sharing_asm_name = node;
       *aslot = node;
 
       /* Update also possible inline clones sharing a decl.  */
@@ -217,13 +208,13 @@ symbol_table::unlink_from_assembler_name_hash (symtab_node *node,
       else
        {
          tree name = DECL_ASSEMBLER_NAME (node->decl);
-          void **slot;
-         slot = htab_find_slot_with_hash (assembler_name_hash, name,
-                                          decl_assembler_name_hash (name),
-                                          NO_INSERT);
+          symtab_node **slot;
+         hashval_t hash = decl_assembler_name_hash (name);
+         slot = assembler_name_hash->find_slot_with_hash (name, hash,
+                                                          NO_INSERT);
          gcc_assert (*slot == node);
          if (!node->next_sharing_asm_name)
-           htab_clear_slot (assembler_name_hash, slot);
+           assembler_name_hash->clear_slot (slot);
          else
            *slot = node->next_sharing_asm_name;
        }
@@ -256,9 +247,7 @@ symbol_table::symtab_initialize_asm_name_hash (void)
   symtab_node *node;
   if (!assembler_name_hash)
     {
-      assembler_name_hash =
-       htab_create_ggc (10, hash_node_by_assembler_name, eq_assembler_name,
-                        NULL);
+      assembler_name_hash = hash_table<asmname_hasher>::create_ggc (10);
       FOR_EACH_SYMBOL (node)
        insert_to_assembler_name_hash (node, false);
     }
@@ -322,20 +311,17 @@ resolution_used_from_other_file_p (enum ld_plugin_symbol_resolution resolution)
 
 /* Hash sections by their names.  */
 
-static hashval_t
-hash_section_hash_entry (const void *p)
+hashval_t
+section_name_hasher::hash (section_hash_entry *n)
 {
-  const section_hash_entry *n = (const section_hash_entry *) p;
   return htab_hash_string (n->name);
 }
 
 /* Return true if section P1 name equals to P2.  */
 
-static int
-eq_sections (const void *p1, const void *p2)
+bool
+section_name_hasher::equal (section_hash_entry *n1, const char *name)
 {
-  const section_hash_entry *n1 = (const section_hash_entry *) p1;
-  const char *name = (const char *)p2;
   return n1->name == name || !strcmp (n1->name, name);
 }
 
@@ -936,16 +922,16 @@ symtab_node *
 symtab_node::get_for_asmname (const_tree asmname)
 {
   symtab_node *node;
-  void **slot;
 
   symtab->symtab_initialize_asm_name_hash ();
-  slot = htab_find_slot_with_hash (symtab->assembler_name_hash, asmname,
-                                  symtab->decl_assembler_name_hash (asmname),
-                                  NO_INSERT);
+  hashval_t hash = symtab->decl_assembler_name_hash (asmname);
+  symtab_node **slot
+    = symtab->assembler_name_hash->find_slot_with_hash (asmname, hash,
+                                                       NO_INSERT);
 
   if (slot)
     {
-      node = (symtab_node *) *slot;
+      node = *slot;
       return node;
     }
   return NULL;
@@ -1382,7 +1368,7 @@ void
 symtab_node::set_section_for_node (const char *section)
 {
   const char *current = get_section ();
-  void **slot;
+  section_hash_entry **slot;
 
   if (current == section
       || (current && section
@@ -1394,11 +1380,11 @@ symtab_node::set_section_for_node (const char *section)
       x_section->ref_count--;
       if (!x_section->ref_count)
        {
-         slot = htab_find_slot_with_hash (symtab->section_hash, x_section->name,
-                                          htab_hash_string (x_section->name),
-                                          INSERT);
+         hashval_t hash = htab_hash_string (x_section->name);
+         slot = symtab->section_hash->find_slot_with_hash (x_section->name,
+                                                           hash, INSERT);
          ggc_free (x_section);
-         htab_clear_slot (symtab->section_hash, slot);
+         symtab->section_hash->clear_slot (slot);
        }
       x_section = NULL;
     }
@@ -1408,11 +1394,10 @@ symtab_node::set_section_for_node (const char *section)
       return;
     }
   if (!symtab->section_hash)
-    symtab->section_hash = htab_create_ggc (10, hash_section_hash_entry,
-                                   eq_sections, NULL);
-  slot = htab_find_slot_with_hash (symtab->section_hash, section,
-                                  htab_hash_string (section),
-                                  INSERT);
+    symtab->section_hash = hash_table<section_name_hasher>::create_ggc (10);
+  slot = symtab->section_hash->find_slot_with_hash (section,
+                                                   htab_hash_string (section),
+                                                   INSERT);
   if (*slot)
     x_section = (section_hash_entry *)*slot;
   else