*** empty log message ***
[libfirm] / ir / tr / type_identify.h
1 /**
2  *
3  * @file type.h
4  *
5  * Project:     libFIRM                                                   <br>
6  * File name:   ir/tr/type.h                                              <br>
7  * Purpose:     Representation of types.                                  <br>
8  * Author:      Goetz Lindenmaier                                         <br>
9  * Modified by:                                                           <br>
10  * Created:                                                               <br>
11  * Copyright:   (c) 2001-2003 Universität Karlsruhe                       <br>
12  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE. <br>
13  * CVS-ID:      $Id$
14  *
15  *
16  */
17
18 # ifndef _TYPE_IDENTIFY_H_
19 # define _TYPE_IDENTIFY_H_
20
21 #ifndef _TYPE_TYPEDEF_
22 #define _TYPE_TYPEDEF_
23 typedef struct type type;
24 #endif
25
26 /* ------------------------------------------------------------------------ */
27
28 /**  Type for a function that compares two types.
29  *
30  *   @param tp1  The first type to compare.
31  *   @param tp2  The second type to compare.
32  */
33 //typedef int (*compare_types_func_tp) (type *tp1, type *tp2);
34 typedef int (*compare_types_func_tp) (const void *tp1, const void *tp2);
35
36 /** Compares two types by their name.
37  *
38  * Compares the opcode and the name of the types. If these are
39  * equal returns true, else false.
40  */
41 int compare_names (const void *tp1, const void *tp2);
42
43 /** Compares two types strict.
44  *
45  * returns true if tp1 == tp2
46  */
47 int compare_strict (const void *tp1, const void *tp2);
48
49 /** A variable that holds a compare function for types.
50  *
51  *  The compare function is used to identify equal types.  The
52  *  variable is initialized with the function compare_strict().
53  *
54  *  The variable must be set before calling init_firm()! Later changes
55  *  have no effect.
56  */
57 extern compare_types_func_tp compare_types_func;
58
59
60 /* ------------------------------------------------------------------------ */
61
62 /**  Type for a function that computes a hash value for a type.
63  *
64  *   @param tp The type to compute a hash for.
65  */
66 typedef int (*hash_types_func_tp)(type *tp);
67
68 /** Computes a hash value by the type name.
69  *
70  * Uses the name of the type and the type opcode to compute the hash.
71  */
72 int hash_name (type *tp);
73
74 /** A variable that holds a hash function for a type.
75  *
76  *  The hash function is used to identify equal types.  The
77  *  variable is initialized with the function hash_name().
78  *
79  *  The variable must be set before calling init_firm()! Later changes
80  *  have no effect.
81  */
82 extern hash_types_func_tp hash_types_func;
83
84
85 /* ------------------------------------------------------------------------ */
86
87 /** Finalize type construction.
88  *
89  * Indicate that a type is so far completed that it can be
90  * distinguished from other types.  Mature_type hashes the type into a
91  * table.  It uses the function in compare_types_func to compare the
92  * types.
93  *
94  * If it finds a type identical to tp it returns this type.  It turns
95  * tp into the Id type.  All places formerly pointing to tp will now
96  * point to the found type.  All entities of tp now refer to the found
97  * type as their owner, but they are not a member of this type.  This
98  * is invalid firm -- the entities must be replaced by entities of the
99  * found type.  The Id type will be removed from the representation
100  * automatically, but within an unknown time span.  It occupies memory
101  * for this time.
102  *
103  * @param tp     The type to mature.
104  */
105 type *       mature_type(type *tp);
106
107 /** Finalize type construction.
108  *
109  * Indicate that a type is so far completed that it can be
110  * distinguished from other types.  Mature_type hashes the type into a
111  * table.  It uses the function in compare_types_func to compare the
112  * types.
113  *
114  * If it finds a type identical to tp it returns this type.  It frees
115  * type tp and all its entities.
116  *
117  * @param tp     The type to mature.
118  */
119 type *       mature_type_free(type *tp);
120
121 /** Finalize type construction.
122  *
123  * Indicate that a type is so far completed that it can be
124  * distinguished from other types.  Mature_type hashes the type into a
125  * table.  It uses the function in compare_types_func to compare the
126  * types.
127  *
128  * If it find a type identical to tp it returns this type.  It frees
129  * the entities and turns the type into an Id type.  All places
130  * formerly pointing to tp will now point to the found type.  The Id
131  * type will be removed from the representation automatically, but
132  * within an unknown time span.  It occupies memory for this time.
133  *
134  * @param tp     The type to mature.
135  */
136 type *       mature_type_free_entities(type *tp);
137
138 # endif /* _TYPE_IDENTIFY_H_ */