Re: [cxx-conversion] tree-related hash tables

2012-12-03 Thread Diego Novillo

On 2012-12-01 20:45 , Lawrence Crowl wrote:


Index: gcc/tree-hasher.h
===
--- gcc/tree-hasher.h   (revision 0)
+++ gcc/tree-hasher.h   (revision 0)
@@ -0,0 +1,56 @@
+/* Data and Control Flow Analysis for Trees.


This is the wrong description for this file.


+   Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012 Free Software Foundation, Inc.
+   Contributed by Diego Novillo dnovi...@redhat.com


Only mention year 2012 and don't blame me for sins I never committed ;)


OK otherwise.


Diego.


Re: [cxx-conversion] tree-related hash tables

2012-12-03 Thread Lawrence Crowl
On 12/3/12, Diego Novillo dnovi...@google.com wrote:
 On 2012-12-01 20:45 , Lawrence Crowl wrote:
 Index: gcc/tree-hasher.h
 ===
 --- gcc/tree-hasher.h(revision 0)
 +++ gcc/tree-hasher.h(revision 0)
 @@ -0,0 +1,56 @@
 +/* Data and Control Flow Analysis for Trees.

 This is the wrong description for this file.

 +   Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
 2011,
 +   2012 Free Software Foundation, Inc.
 +   Contributed by Diego Novillo dnovi...@redhat.com

 Only mention year 2012 and don't blame me for sins I never committed ;)

The dreaded copy and fail to fully edit.

Fixed.

 OK otherwise.

Thanks.

-- 
Lawrence Crowl


[cxx-conversion] tree-related hash tables

2012-12-01 Thread Lawrence Crowl
Change tree-related hash tables from htab_t to hash_table:

tree-complex.c complex_variable_components
tree-parloops.c eliminate_local_variables_stmt::decl_address
tree-parloops.c separate_decls_in_region::decl_copies

Move hash table declarations to a new tree-hasher.h, to resolve
compilation dependences and because they are used in few places.


Tested on x86-64.

Okay for branch?


Index: gcc/ChangeLog

2012-11-30  Lawrence Crowl  cr...@google.com

* tree-hasher.h: New.
(struct int_tree_hasher): New.
(typedef int_tree_htab_type): New.

* tree-flow.h (extern int_tree_map_hash): Moved into tree-hasher
struct int_tree_hasher.
(extern int_tree_map_eq): Likewise.

* tree-complex.c: Include tree-hasher.h
(htab_t complex_variable_components):
Change type to hash_table.  Update dependent calls and types.

* tree-parloops.c: Include tree-hasher.h.
(htab_t eliminate_local_variables_stmt::decl_address):
Change type to hash_table.  Update dependent calls and types.
(htab_t separate_decls_in_region::decl_copies): Likewise.

* tree-ssa.c (int_tree_map_eq): Moved into struct int_tree_hasher
in tree-flow.h.
(int_tree_map_hash): Likewise.

* Makefile.in: Update to changes above.

Index: gcc/tree-complex.c
===
--- gcc/tree-complex.c  (revision 193902)
+++ gcc/tree-complex.c  (working copy)
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3.
 #include tree-iterator.h
 #include tree-pass.h
 #include tree-ssa-propagate.h
+#include tree-hasher.h


 /* For each complex ssa name, a lattice value.  We're interested in finding
@@ -54,7 +55,7 @@ static veccomplex_lattice_t complex_la

 /* For each complex variable, a pair of variables for the components exists in
the hashtable.  */
-static htab_t complex_variable_components;
+static int_tree_htab_type complex_variable_components;

 /* For each complex SSA_NAME, a pair of ssa names for the components.  */
 static vectree complex_ssa_name_components;
@@ -66,7 +67,7 @@ cvc_lookup (unsigned int uid)
 {
   struct int_tree_map *h, in;
   in.uid = uid;
-  h = (struct int_tree_map *) htab_find_with_hash
(complex_variable_components, in, uid);
+  h = complex_variable_components.find_with_hash (in, uid);
   return h ? h-to : NULL;
 }

@@ -76,14 +77,13 @@ static void
 cvc_insert (unsigned int uid, tree to)
 {
   struct int_tree_map *h;
-  void **loc;
+  int_tree_map **loc;

   h = XNEW (struct int_tree_map);
   h-uid = uid;
   h-to = to;
-  loc = htab_find_slot_with_hash (complex_variable_components, h,
- uid, INSERT);
-  *(struct int_tree_map **) loc = h;
+  loc = complex_variable_components.find_slot_with_hash (h, uid, INSERT);
+  *loc = h;
 }

 /* Return true if T is not a zero constant.  In the case of real values,
@@ -1569,8 +1569,7 @@ tree_lower_complex (void)
   init_parameter_lattice_values ();
   ssa_propagate (complex_visit_stmt, complex_visit_phi);

-  complex_variable_components = htab_create (10,  int_tree_map_hash,
-int_tree_map_eq, free);
+  complex_variable_components.create (10);

   complex_ssa_name_components.create (2 * num_ssa_names);
   complex_ssa_name_components.safe_grow_cleared (2 * num_ssa_names);
@@ -1591,7 +1590,7 @@ tree_lower_complex (void)

   gsi_commit_edge_inserts ();

-  htab_delete (complex_variable_components);
+  complex_variable_components.dispose ();
   complex_ssa_name_components.release ();
   complex_lattice_values.release ();
   return 0;
Index: gcc/tree-hasher.h
===
--- gcc/tree-hasher.h   (revision 0)
+++ gcc/tree-hasher.h   (revision 0)
@@ -0,0 +1,56 @@
+/* Data and Control Flow Analysis for Trees.
+   Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012 Free Software Foundation, Inc.
+   Contributed by Diego Novillo dnovi...@redhat.com
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+http://www.gnu.org/licenses/.  */
+
+#ifndef GCC_TREE_HASHER_H
+#define GCC_TREE_HASHER_H 1
+
+#include hash-table.h
+#include tree-flow.h
+
+/* Hashtable helpers.  */
+
+struct int_tree_hasher : typed_free_remove int_tree_map
+{
+  typedef int_tree_map value_type;
+  typedef int_tree_map compare_type;
+  static inline hashval_t hash (const