5 * Project: libFIRM <br>
6 * File name: ir/tr/type.h <br>
7 * Purpose: Representation of types. <br>
8 * Author: Goetz Lindenmaier <br>
11 * Copyright: (c) 2001-2003 Universität Karlsruhe <br>
12 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. <br>
18 # ifndef _TYPE_IDENTIFY_H_
19 # define _TYPE_IDENTIFY_H_
21 #ifndef _TYPE_TYPEDEF_
22 #define _TYPE_TYPEDEF_
23 typedef struct type type;
26 /* ------------------------------------------------------------------------ */
28 /** Type for a function that compares two types.
30 * @param tp1 The first type to compare.
31 * @param tp2 The second type to compare.
33 typedef int (*compare_types_func_tp) (const void *tp1, const void *tp2);
35 /** Compares two types by their name.
37 * Compares the opcode and the name of the types. If these are
38 * equal returns 0, else non-zero.
40 int compare_names (const void *tp1, const void *tp2);
42 /** Compares two types strict.
44 * returns 0 if tp1 == tp2, else non-zero
46 int compare_strict (const void *tp1, const void *tp2);
48 /** A variable that holds a compare function for types.
50 * The compare function is used to identify equal types. The
51 * variable is initialized with the function compare_strict().
53 * The variable must be set before calling init_firm()! Later changes
56 extern compare_types_func_tp compare_types_func;
59 /* ------------------------------------------------------------------------ */
61 /** Type for a function that computes a hash value for a type.
63 * @param tp The type to compute a hash for.
65 typedef int (*hash_types_func_tp)(type *tp);
67 /** Computes a hash value by the type name.
69 * Uses the name of the type and the type opcode to compute the hash.
71 int hash_name (type *tp);
73 /** A variable that holds a hash function for a type.
75 * The hash function is used to identify equal types. The
76 * variable is initialized with the function hash_name().
78 * The variable must be set before calling init_firm()! Later changes
81 extern hash_types_func_tp hash_types_func;
84 /* ------------------------------------------------------------------------ */
86 /** Finalize type construction.
88 * Indicate that a type is so far completed that it can be
89 * distinguished from other types. Mature_type hashes the type into a
90 * table. It uses the function in compare_types_func to compare the
93 * If it finds a type identical to tp it returns this type. It turns
94 * tp into the Id type. All places formerly pointing to tp will now
95 * point to the found type. All entities of tp now refer to the found
96 * type as their owner, but they are not a member of this type. This
97 * is invalid firm -- the entities must be replaced by entities of the
98 * found type. The Id type will be removed from the representation
99 * automatically, but within an unknown time span. It occupies memory
102 * @param tp The type to mature.
104 type * mature_type(type *tp);
106 /** Finalize type construction.
108 * Indicate that a type is so far completed that it can be
109 * distinguished from other types. Mature_type hashes the type into a
110 * table. It uses the function in compare_types_func to compare the
113 * If it finds a type identical to tp it returns this type. It frees
114 * type tp and all its entities.
116 * @param tp The type to mature.
118 type * mature_type_free(type *tp);
120 /** Finalize type construction.
122 * Indicate that a type is so far completed that it can be
123 * distinguished from other types. Mature_type hashes the type into a
124 * table. It uses the function in compare_types_func to compare the
127 * If it find a type identical to tp it returns this type. It frees
128 * the entities and turns the type into an Id type. All places
129 * formerly pointing to tp will now point to the found type. The Id
130 * type will be removed from the representation automatically, but
131 * within an unknown time span. It occupies memory for this time.
133 * @param tp The type to mature.
135 type * mature_type_free_entities(type *tp);
138 * initialise the type identifier module.
140 void init_type_identify(void);
142 # endif /* _TYPE_IDENTIFY_H_ */