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) (type *tp1, type *tp2);
34 typedef int (*compare_types_func_tp) (const void *tp1, const void *tp2);
36 /** Compares two types by their name.
38 * Compares the opcode and the name of the types. If these are
39 * equal returns true, else false.
41 int compare_names (const void *tp1, const void *tp2);
43 /** Compares two types strict.
45 * returns true if tp1 == tp2
47 int compare_strict (const void *tp1, const void *tp2);
49 /** A variable that holds a compare function for types.
51 * The compare function is used to identify equal types. The
52 * variable is initialized with the function compare_strict().
54 * The variable must be set before calling init_firm()! Later changes
57 extern compare_types_func_tp compare_types_func;
60 /* ------------------------------------------------------------------------ */
62 /** Type for a function that computes a hash value for a type.
64 * @param tp The type to compute a hash for.
66 typedef int (*hash_types_func_tp)(type *tp);
68 /** Computes a hash value by the type name.
70 * Uses the name of the type and the type opcode to compute the hash.
72 int hash_name (type *tp);
74 /** A variable that holds a hash function for a type.
76 * The hash function is used to identify equal types. The
77 * variable is initialized with the function hash_name().
79 * The variable must be set before calling init_firm()! Later changes
82 extern hash_types_func_tp hash_types_func;
85 /* ------------------------------------------------------------------------ */
87 /** Finalize type construction.
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
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
103 * @param tp The type to mature.
105 type * mature_type(type *tp);
107 /** Finalize type construction.
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
114 * If it finds a type identical to tp it returns this type. It frees
115 * type tp and all its entities.
117 * @param tp The type to mature.
119 type * mature_type_free(type *tp);
121 /** Finalize type construction.
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
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.
134 * @param tp The type to mature.
136 type * mature_type_free_entities(type *tp);
138 # endif /* _TYPE_IDENTIFY_H_ */