projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added phase reinit data per irn
[libfirm]
/
ir
/
tr
/
type_identify.c
diff --git
a/ir/tr/type_identify.c
b/ir/tr/type_identify.c
index
cbf76d7
..
70b8998
100644
(file)
--- a/
ir/tr/type_identify.c
+++ b/
ir/tr/type_identify.c
@@
-1,6
+1,6
@@
/*
* Project: libFIRM
/*
* Project: libFIRM
- * File name: ir/tr/type.c
+ * File name: ir/tr/type
_identify
.c
* Purpose: Representation of types.
* Author: Goetz Lindenmaier
* Modified by:
* Purpose: Representation of types.
* Author: Goetz Lindenmaier
* Modified by:
@@
-11,18
+11,18
@@
*/
/**
*/
/**
- *
file type.c - implementation of the datastructure to hold
- *
type information.
+ *
@file type_identify.c
+ *
* (C) 2004 by Universitaet Karlsruhe
* Goetz Lindenmaier
*
*/
#ifdef HAVE_CONFIG_H
* (C) 2004 by Universitaet Karlsruhe
* Goetz Lindenmaier
*
*/
#ifdef HAVE_CONFIG_H
-# include
<config.h>
+# include
"config.h"
#endif
#endif
-#include "type_identify.h"
+#include "type_identify
_t
.h"
#include <stdlib.h>
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
@@
-36,14
+36,18
@@
#include "irprog_t.h"
#include "mangle.h"
#include "pset.h"
#include "irprog_t.h"
#include "mangle.h"
#include "pset.h"
+#include "irtools.h"
/* The hash set for types. */
static pset *type_table = NULL;
/* 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) {
int compare_names (const void *tp1, const void *tp2) {
-
type *t1 = (
type *) tp1;
-
type *t2 = (
type *) tp2;
+
ir_type *t1 = (ir_
type *) tp1;
+
ir_type *t2 = (ir_
type *) tp2;
return (t1 != t2 &&
(t1->type_op != t2->type_op ||
return (t1 != t2 &&
(t1->type_op != t2->type_op ||
@@
-52,26
+56,21
@@
int compare_names (const void *tp1, const void *tp2) {
/* stuff for comparing two types. */
int compare_strict (const void *tp1, const void *tp2) {
/* stuff for comparing two types. */
int compare_strict (const void *tp1, const void *tp2) {
-
type *t1 = (
type *) tp1;
-
type *t2 = (
type *) tp2;
+
ir_type *t1 = (ir_
type *) tp1;
+
ir_type *t2 = (ir_
type *) tp2;
return t1 != t2;
}
return t1 != t2;
}
-compare_types_func_tp compare_types_func = compare_strict;
-
/* stuff to compute a hash value for a type. */
/* stuff to compute a hash value for a type. */
-int
hash_name (
type *tp) {
- unsigned h = (unsigned)
tp->type_op
;
- h = 9*h + (unsigned)
tp->name
;
+int
firm_hash_name (ir_
type *tp) {
+ unsigned h = (unsigned)
PTR_TO_INT(tp->type_op)
;
+ h = 9*h + (unsigned)
PTR_TO_INT(tp->name)
;
return h;
}
return h;
}
-hash_types_func_tp hash_types_func = hash_name;
-
-
/* The function that hashes a type. */
/* The function that hashes a type. */
-
type *mature_type(
type *tp) {
- type *o;
+
ir_type *mature_type(ir_
type *tp) {
+
ir_
type *o;
assert(type_table);
assert(type_table);
@@
-86,8
+85,8
@@
type *mature_type(type *tp) {
/* The function that hashes a type. */
/* The function that hashes a type. */
-
type *mature_type_free(
type *tp) {
- type *o;
+
ir_type *mature_type_free(ir_
type *tp) {
+
ir_
type *o;
assert(type_table);
assert(type_table);
@@
-102,8
+101,8
@@
type *mature_type_free(type *tp) {
}
/* The function that hashes a type. */
}
/* The function that hashes a type. */
-
type *mature_type_free_entities(
type *tp) {
- type *o;
+
ir_type *mature_type_free_entities(ir_
type *tp) {
+
ir_
type *o;
assert(type_table);
assert(type_table);
@@
-117,6
+116,10
@@
type *mature_type_free_entities(type *tp) {
return o;
}
return o;
}
-void init_type_identify(void) {
+/* initialize this module */
+void init_type_identify(type_identify_if_t *ti_if) {
+ compare_types_func = ti_if && ti_if->cmp ? ti_if->cmp : compare_strict;
+ hash_types_func = ti_if && ti_if->hash ? ti_if->hash : firm_hash_name;
+
type_table = new_pset (compare_types_func, 8);
}
type_table = new_pset (compare_types_func, 8);
}