X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftr%2Ftype_identify.h;h=85bc34fd9d00ba36ec3165d86aba9b2a381c0115;hb=8ac7f010beb0c30fcbae390e6582661f9f98d417;hp=ed3637e2731a82c9e2a54e0fd85c69b8ba2a4cf6;hpb=649db362d8fe7e54a1589cf0abce5662b445572b;p=libfirm diff --git a/ir/tr/type_identify.h b/ir/tr/type_identify.h index ed3637e27..85bc34fd9 100644 --- a/ir/tr/type_identify.h +++ b/ir/tr/type_identify.h @@ -1,5 +1,4 @@ /** - * * @file type.h * * Project: libFIRM
@@ -18,10 +17,7 @@ # ifndef _TYPE_IDENTIFY_H_ # define _TYPE_IDENTIFY_H_ -#ifndef _TYPE_TYPEDEF_ -#define _TYPE_TYPEDEF_ -typedef struct type type; -#endif +#include "firm_types.h" /* ------------------------------------------------------------------------ */ @@ -30,57 +26,34 @@ typedef struct type type; * @param tp1 The first type to compare. * @param tp2 The second type to compare. */ -//typedef int (*compare_types_func_tp) (type *tp1, type *tp2); -typedef int (*compare_types_func_tp) (const void *tp1, const void *tp2); +typedef int (compare_types_func_t)(const void *tp1, const void *tp2); /** Compares two types by their name. * * Compares the opcode and the name of the types. If these are - * equal returns true, else false. + * equal returns 0, else non-zero. */ int compare_names (const void *tp1, const void *tp2); /** Compares two types strict. * - * returns true if tp1 == tp2 + * returns 0 if tp1 == tp2, else non-zero */ int compare_strict (const void *tp1, const void *tp2); -/** A variable that holds a compare function for types. - * - * The compare function is used to identify equal types. The - * variable is initialized with the function compare_strict(). - * - * The variable must be set before calling init_firm()! Later changes - * have no effect. - */ -extern compare_types_func_tp compare_types_func; - - /* ------------------------------------------------------------------------ */ /** Type for a function that computes a hash value for a type. * * @param tp The type to compute a hash for. */ -typedef int (*hash_types_func_tp)(type *tp); +typedef int (hash_types_func_t)(ir_type *tp); /** Computes a hash value by the type name. * * Uses the name of the type and the type opcode to compute the hash. */ -int hash_name (type *tp); - -/** A variable that holds a hash function for a type. - * - * The hash function is used to identify equal types. The - * variable is initialized with the function hash_name(). - * - * The variable must be set before calling init_firm()! Later changes - * have no effect. - */ -extern hash_types_func_tp hash_types_func; - +int firm_hash_name (ir_type *tp); /* ------------------------------------------------------------------------ */ @@ -102,7 +75,7 @@ extern hash_types_func_tp hash_types_func; * * @param tp The type to mature. */ -type * mature_type(type *tp); +ir_type * mature_type(ir_type *tp); /** Finalize type construction. * @@ -116,7 +89,7 @@ type * mature_type(type *tp); * * @param tp The type to mature. */ -type * mature_type_free(type *tp); +ir_type * mature_type_free(ir_type *tp); /** Finalize type construction. * @@ -133,6 +106,26 @@ type * mature_type_free(type *tp); * * @param tp The type to mature. */ -type * mature_type_free_entities(type *tp); +ir_type * mature_type_free_entities(ir_type *tp); + +/** + * The interface type for the type identify module; + */ +typedef struct _type_identify_if_t { + compare_types_func_t *cmp; /**< The function that should be used to compare two types. + If NULL, compare_strict() will be used. */ + hash_types_func_t *hash; /**< The function that should be used to calculate a hash + value of a type. If NULL, hash_name() will be used. */ +} type_identify_if_t; + +/** + * Initialise the type identifier module. + * + * @param ti_if The interface functions for this module. + * + * If the parameter ti_if is NULL, the default functions compare_strict() and + * firm_hash_name() will be used. + */ +void init_type_identify(type_identify_if_t *ti_if); # endif /* _TYPE_IDENTIFY_H_ */