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
92 * types. If it find a type identical to tp it returns this type. In
93 * this case it also turns tp into the Id type. The caller should free
94 * tp if he knows that there are no other references to tp. The memory
95 * of tp is not lost, but will remain alive for an unknown time.
97 * @param tp The type to mature.
99 type * mature_type(type *tp);
101 # endif /* _TYPE_IDENTIFY_H_ */