X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fstat%2Fpattern.c;h=20c871906ef420f7c0deab819a76d31caef2f8f6;hb=b4647d67ab7885d5da32c2a30242fbc4ed93d81b;hp=d116f2ddcd8b9558bf735a3dba9199e97ec44ae7;hpb=7c36344d22a7c306a4e216f135c974bdb9f6b943;p=libfirm diff --git a/ir/stat/pattern.c b/ir/stat/pattern.c index d116f2ddc..20c871906 100644 --- a/ir/stat/pattern.c +++ b/ir/stat/pattern.c @@ -54,13 +54,13 @@ typedef pset pset_pattern_entry_t; typedef unsigned char BYTE; /** Maximum size of the pattern store. */ -#define PATTERN_STORE_SIZE 2048 +#define PATTERN_STORE_SIZE 2048 /** * The code buffer. */ -typedef struct _code_buf_t { +typedef struct code_buf_t { BYTE *next; /**< Next byte address to be written. */ BYTE *end; /**< End address of the buffer. */ BYTE *start; /**< Start address of the buffer. */ @@ -89,7 +89,7 @@ enum vlc_code_t { /* * An entry for holding one pattern. */ -typedef struct _pattern_entry_t { +typedef struct pattern_entry_t { counter_t count; /**< Amount of pattern occurance. */ unsigned len; /**< The length of the VLC encoded buffer. */ BYTE buf[1]; /**< The buffer containing the VLC encoded pattern. */ @@ -109,7 +109,7 @@ enum options_t { /** * Pattern info. */ -typedef struct _pattern_info_t { +typedef struct pattern_info_t { int enable; /**< If non-zero, this module is enabled. */ struct obstack obst; /**< An obstack containing the counters. */ HASH_MAP(pattern_entry_t) *pattern_hash; /**< A hash map containing the pattern. */ @@ -367,7 +367,7 @@ static BYTE next_tag(CODE_BUFFER *buf) /** * An Environment for the pattern encoder. */ -typedef struct _codec_enc_t { +typedef struct codec_enc_t { CODE_BUFFER *buf; /**< The current code buffer. */ set *id_set; /**< A set containing all already seen Firm nodes. */ unsigned curr_id; /**< The current node id. */ @@ -378,7 +378,7 @@ typedef struct _codec_enc_t { /** * An address entry. */ -typedef struct _addr_entry_t { +typedef struct addr_entry_t { void *addr; /**< the address */ unsigned id; /**< associated ID */ } addr_entry_t; @@ -395,6 +395,18 @@ static int addr_cmp(const void *p1, const void *p2, size_t size) return e1->addr != e2->addr; } /* addr_cmp */ +static unsigned find_mode_index(const ir_mode *mode) +{ + int n = get_irp_n_modes(); + int i; + + for (i = 0; i < n; ++i) { + if (get_irp_mode(i) == mode) + return i; + } + return -1; +} + /** * Encodes an IR-node, recursive worker. * @@ -434,7 +446,7 @@ static int _encode_node(ir_node *node, int max_depth, codec_env_t *env) ir_mode *mode = get_irn_mode(node); if (mode) - put_code(env->buf, stat_find_mode_index(mode)); + put_code(env->buf, find_mode_index(mode)); else put_tag(env->buf, VLC_TAG_EMPTY); } /* if */ @@ -442,7 +454,7 @@ static int _encode_node(ir_node *node, int max_depth, codec_env_t *env) /* do we need integer constants */ if (env->options & OPT_WITH_ICONST) { if (code == iro_Const) { - tarval *tv = get_Const_tarval(node); + ir_tarval *tv = get_Const_tarval(node); if (tarval_is_long(tv)) { long v = get_tarval_long(tv); @@ -647,7 +659,7 @@ static void decode_node(BYTE *b, unsigned len, pattern_dumper_t *dump) /** * The environment for the pattern calculation. */ -typedef struct _pattern_env { +typedef struct pattern_env { int max_depth; /**< maximum depth for pattern generation. */ } pattern_env_t;