- BYTE *next; /**< next byte to be written */
- BYTE *end; /**< end of the buffer */
- BYTE *start; /**< start of the buffer */
- unsigned hash; /**< calculates the hash value */
+ BYTE *next; /**< next byte to be written */
+ BYTE *end; /**< end of the buffer */
+ BYTE *start; /**< start of the buffer */
+ unsigned hash; /**< calculates the hash value */
- VLC_7BIT = 0x00, /**< 8 bit code, carrying 7 bits payload */
- VLC_14BIT = 0x80, /**< 16 bit code, carrying 14 bits payload */
- VLC_21BIT = 0xC0, /**< 24 bit code, carrying 21 bits payload */
- VLC_28BIT = 0xE0, /**< 32 bit code, carrying 28 bits payload */
- VLC_32BIT = 0xF0, /**< 40 bit code, carrying 32 bits payload */
-
- VLC_TAG_FIRST = 0xF1, /**< first possible tag value */
- VLC_TAG_ICONST = 0xFB, /**< encodes an integer constant */
- VLC_TAG_EMPTY = 0xFC, /**< encodes an empty entity */
- VLC_TAG_OPTION = 0xFD, /**< options exists */
- VLC_TAG_REF = 0xFE, /**< special tag, next code is an ID */
- VLC_TAG_END = 0xFF, /**< end tag */
+ VLC_7BIT = 0x00, /**< 8 bit code, carrying 7 bits payload */
+ VLC_14BIT = 0x80, /**< 16 bit code, carrying 14 bits payload */
+ VLC_21BIT = 0xC0, /**< 24 bit code, carrying 21 bits payload */
+ VLC_28BIT = 0xE0, /**< 32 bit code, carrying 28 bits payload */
+ VLC_32BIT = 0xF0, /**< 40 bit code, carrying 32 bits payload */
+
+ VLC_TAG_FIRST = 0xF1, /**< first possible tag value */
+ VLC_TAG_ICONST = 0xFB, /**< encodes an integer constant */
+ VLC_TAG_EMPTY = 0xFC, /**< encodes an empty entity */
+ VLC_TAG_OPTION = 0xFD, /**< options exists */
+ VLC_TAG_REF = 0xFE, /**< special tag, next code is an ID */
+ VLC_TAG_END = 0xFF, /**< end tag */
- OPT_WITH_MODE = 0x00000001, /**< use modes */
- OPT_ENC_GRAPH = 0x00000002, /**< encode graphs, not terms */
+ OPT_WITH_MODE = 0x00000001, /**< use modes */
+ OPT_ENC_DAG = 0x00000002, /**< encode DAGs, not terms */
- CODE_BUFFER *buf; /**< the code buffer */
- set *id_set; /**< the set containing all already seen nodes */
- unsigned curr_id; /**< current node id */
- unsigned options; /**< encoding options */
- pattern_dumper_t *dmp; /**< dumper for the decoder */
+ CODE_BUFFER *buf; /**< the code buffer */
+ set *id_set; /**< the set containing all already seen nodes */
+ unsigned curr_id; /**< current node id */
+ unsigned options; /**< encoding options */
+ pattern_dumper_t *dmp; /**< dumper for the decoder */
- * walker for nodes pattern calculation
+ * count a pattern
+ */
+static void count_pattern(CODE_BUFFER *buf, int depth) {
+ pattern_entry_t *entry;
+
+ /* ignore single node pattern (i.e. constants) */
+ if (depth > 1) {
+ entry = pattern_get_entry(buf, status->pattern_hash);
+
+ /* increase count */
+ cnt_inc(&entry->count);
+ }
+}
+
+/**
+ * pre-walker for nodes pattern calculation
*/
static void calc_nodes_pattern(ir_node *node, void *ctx)
{
BYTE buffer[1024];
pattern_env_t *env = ctx;
CODE_BUFFER buf;
*/
static void calc_nodes_pattern(ir_node *node, void *ctx)
{
BYTE buffer[1024];
pattern_env_t *env = ctx;
CODE_BUFFER buf;
int depth;
init_buf(&buf, buffer, sizeof(buffer));
depth = encode_node(node, &buf, env->max_depth);
int depth;
init_buf(&buf, buffer, sizeof(buffer));
depth = encode_node(node, &buf, env->max_depth);
- /* ignore single node pattern (i.e. constants) */
- if (depth > 1) {
- entry = pattern_get_entry(&buf, status->pattern_hash);
-
- /* increase count */
- cnt_inc(&entry->count);
- }
+ count_pattern(&buf, depth);