flag for strength reduction verbosity
[libfirm] / ir / tr / type_identify.c
index 1780362..499fcec 100644 (file)
@@ -11,9 +11,8 @@
  */
 
 /**
- *
- *   file type.c - implementation of the datastructure to hold
- *   type information.
+ *  file type.c - implementation of the datastructure to hold
+ *  type information.
  *  (C) 2004 by Universitaet Karlsruhe
  *  Goetz Lindenmaier
  *
 # include <config.h>
 #endif
 
-#include "type_identify.h"
-
-# include <stdlib.h>
-# include <stddef.h>
-# include <string.h>
-# include "type_t.h"
-# include "tpop_t.h"
-# include "irprog_t.h"
-# include "typegmod.h"
-# include "array.h"
-# include "irprog.h"
-# include "mangle.h"
+#include "type_identify_t.h"
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "type_t.h"
+#include "tpop_t.h"
+#include "irprog_t.h"
+#include "typegmod.h"
+#include "array.h"
+#include "irprog_t.h"
+#include "mangle.h"
 #include "pset.h"
 
 /* The hash set for types. */
 static pset *type_table = NULL;
 
+/* hash and compare types */
+static hash_types_func_t    *hash_types_func;
+static compare_types_func_t *compare_types_func;
 
 int compare_names (const void *tp1, const void *tp2) {
   type *t1 = (type *) tp1;
@@ -50,17 +53,13 @@ int compare_names (const void *tp1, const void *tp2) {
           t1->name    !=  t2->name      )  );
 }
 
-
 /* stuff for comparing two types. */
-//int compare_strict (type *tp1, type *tp2) {
 int compare_strict (const void *tp1, const void *tp2) {
   type *t1 = (type *) tp1;
   type *t2 = (type *) tp2;
   return t1 != t2;
 }
 
-compare_types_func_tp compare_types_func = compare_strict;
-
 /* stuff to compute a hash value for a type. */
 int hash_name (type *tp) {
   unsigned h = (unsigned)tp->type_op;
@@ -68,9 +67,6 @@ int hash_name (type *tp) {
   return h;
 }
 
-hash_types_func_tp hash_types_func = hash_name;
-
-
 /* The function that hashes a type. */
 type *mature_type(type *tp) {
   type *o;
@@ -119,9 +115,10 @@ type *mature_type_free_entities(type *tp) {
   return o;
 }
 
-void init_type_identify(void) {
-  //type_table = new_pset ((int (const void *, const void *))compare_types_func, 8);
+/* initialize this module */
+void init_type_identify(compare_types_func_t *cmp, hash_types_func_t *hash) {
+  compare_types_func = cmp  ? cmp  : compare_strict;
+  hash_types_func    = hash ? hash : hash_name;
 
   type_table = new_pset (compare_types_func, 8);
-  //type_table = new_pset (compare_names, 8);
 }