/*
- * Copyright (C) 1995-2010 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
static void reg_map_to_arr(reg_node_map_t *res, pmap *reg_map)
{
pmap_entry *ent;
- int n = pmap_count(reg_map);
- int i = 0;
+ size_t n = pmap_count(reg_map);
+ size_t i = 0;
foreach_pmap(reg_map, ent) {
res[i].reg = (const arch_register_t*)ent->key;
dbg_info *dbgi;
pmap *reg_map = pmap_create();
ir_node *keep = (ir_node*)pmap_get(env->keep_map, bl);
- int in_max;
+ size_t in_max;
ir_node *ret;
int i, n;
unsigned pop;
/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
num = h->next_type_nr++;
pmap_insert(h->type_map, tp, INT_TO_PTR(num));
} else {
- num = PTR_TO_INT(entry->value);
+ num = (unsigned)PTR_TO_INT(entry->value);
}
return num;
} /* get_type_number */
/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
#include "irnodeset.h"
#include "irpass.h"
#include "tv_t.h"
+#include "irtools.h"
#include "irprintf.h"
#include "irdump.h"
*/
static unsigned opcode_hash(const opcode_key_t *entry)
{
- return (entry->mode - (ir_mode *)0) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.ptr) + entry->arity;
+ return (unsigned)(PTR_TO_INT(entry->mode) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.ptr) + entry->arity);
} /* opcode_hash */
/**
/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
#include "set.h"
#include "irpass.h"
#include "debug.h"
+#include "irtools.h"
/* define this for general block shaping: congruent blocks
are found not only before the end block but anywhere in the graph */
static unsigned opcode_hash(const opcode_key_t *entry)
{
/* assume long >= int */
- return (entry->mode - (ir_mode *)0) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.addr) + entry->arity;
+ return (unsigned)(PTR_TO_INT(entry->mode) * 9 + entry->code + entry->u.proj * 3 + HASH_PTR(entry->u.addr) + entry->arity);
} /* opcode_hash */
/**
/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
memop_t **curr_id_2_memop; /**< current map of address ids to memops */
unsigned curr_adr_id; /**< number for address mapping */
unsigned n_mem_ops; /**< number of memory operations (Loads/Stores) */
- unsigned rbs_size; /**< size of all bitsets in bytes */
+ size_t rbs_size; /**< size of all bitsets in bytes */
int max_cfg_preds; /**< maximum number of block cfg predecessors */
int changed; /**< Flags for changed graph state */
#ifdef DEBUG_libfirm
*/
static void dump_curr(block_t *bl, const char *s)
{
- unsigned end = env.rbs_size - 1;
- unsigned pos;
- int i;
+ size_t end = env.rbs_size - 1;
+ size_t pos;
+ int i;
DB((dbg, LEVEL_2, "%s[%+F] = {", s, bl->block));
i = 0;
*/
static void kill_memops(const value_t *value)
{
- unsigned end = env.rbs_size - 1;
- unsigned pos;
+ size_t end = env.rbs_size - 1;
+ size_t pos;
for (pos = rbitset_next(env.curr_set, 0, 1); pos < end; pos = rbitset_next(env.curr_set, pos + 1, 1)) {
memop_t *op = env.curr_id_2_memop[pos];
ir_node *succ = get_Block_cfg_out(block, 0);
block_t *succ_bl = get_block_entry(succ);
int pred_pos = get_Block_cfgpred_pos(succ, block);
- unsigned end = env.rbs_size - 1;
- unsigned pos;
+ size_t end = env.rbs_size - 1;
+ size_t pos;
kill_all();
{
ir_node *block = bl->block;
int i, n = get_Block_n_cfgpreds(block);
- unsigned end = env.rbs_size - 1;
- unsigned pos;
+ size_t end = env.rbs_size - 1;
+ size_t pos;
DB((dbg, LEVEL_3, "processing %+F\n", block));
}
/*
* Ensure that all values are in the map: build Phi's if necessary:
- * Note: the last bit is the sentinel and ALWAYS set, so start with -2.
+ * Note: the last bit is the sentinel and ALWAYS set, so end with -2.
*/
- for (pos = env.rbs_size - 2; pos >= 0; --pos) {
+ for (pos = 0; pos < env.rbs_size - 1; ++pos) {
if (! rbitset_is_set(env.curr_set, pos))
env.curr_id_2_memop[pos] = NULL;
else {
/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
ir_node *mem_op;
ir_node *pred;
ir_node *block;
- int n;
+ size_t n;
parallelize_info pi;
(void)env;
/*
- * Copyright (C) 1995-2010 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
double stat_calc_mean_distrib_tbl(distrib_tbl_t *tbl)
{
distrib_entry_t *entry;
- unsigned count;
+ size_t count;
double sum;
if (tbl->int_dist) {
double stat_calc_avg_distrib_tbl(distrib_tbl_t *tbl)
{
distrib_entry_t *entry;
- unsigned count = 0;
+ size_t count = 0;
double sum = 0.0;
if (tbl->int_dist) {
/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
#include "pattern_dmp.h"
#include "hashptr.h"
#include "error.h"
+#include "lc_printf.h"
#ifdef FIRM_STATISTICS
*/
typedef struct pattern_entry_t {
counter_t count; /**< Amount of pattern occurance. */
- unsigned len; /**< The length of the VLC encoded buffer. */
+ size_t len; /**< The length of the VLC encoded buffer. */
BYTE buf[1]; /**< The buffer containing the VLC encoded pattern. */
} pattern_entry_t;
{
const pattern_entry_t *e1 = (const pattern_entry_t*)elt;
const pattern_entry_t *e2 = (const pattern_entry_t*)key;
- int diff = e1->len - e2->len;
- if (diff)
- return diff;
+ if (e1->len == e2->len)
+ return memcmp(e1->buf, e2->buf, e1->len);
- return memcmp(e1->buf, e2->buf, e1->len);
+ return e1->len < e2->len ? -1 : +1;
} /* pattern_cmp */
/**
* @param data a buffer address
* @param len the length of the data buffer
*/
-static void init_buf(CODE_BUFFER *buf, BYTE *data, unsigned len)
+static void init_buf(CODE_BUFFER *buf, BYTE *data, size_t len)
{
buf->start =
buf->next = data;
*
* @return the length of the buffer content
*/
-static unsigned buf_lenght(const CODE_BUFFER *buf)
+static size_t buf_lenght(const CODE_BUFFER *buf)
{
return buf->next - buf->start;
} /* buf_lenght */
/**
* Decode an IR-node.
*/
-static void decode_node(BYTE *b, unsigned len, pattern_dumper_t *dump)
+static void decode_node(BYTE *b, size_t len, pattern_dumper_t *dump)
{
codec_env_t env;
CODE_BUFFER buf;
static pattern_entry_t *pattern_get_entry(CODE_BUFFER *buf, pset *set)
{
pattern_entry_t *key, *elem;
- unsigned len = buf_lenght(buf);
+ size_t len = buf_lenght(buf);
unsigned hash;
key = OALLOCF(&status->obst, pattern_entry_t, buf, len);
depth = encode_node(node, &buf, env->max_depth);
if (buf_overrun(&buf)) {
- fprintf(stderr, "Pattern store: buffer overrun at size %u. Pattern ignored.\n", (unsigned) sizeof(buffer));
+ lc_fprintf(stderr, "Pattern store: buffer overrun at size %zu. Pattern ignored.\n", sizeof(buffer));
} else
count_pattern(&buf, depth);
} /* calc_nodes_pattern */
{
FILE *f;
pattern_entry_t *entry;
- int i, count = pset_count(status->pattern_hash);
+ size_t i, count = pset_count(status->pattern_hash);
if (count <= 0)
return;
{
FILE *f;
pattern_entry_t *entry, tmp;
- int i, count;
+ size_t i, count;
unsigned j;
char magic[4];
HASH_MAP(pattern_entry_t) *pattern_hash = new_pset(pattern_cmp, 8);
} /* for */
fclose(f);
- printf("Read %d pattern from %s\n", count, fname);
+ lc_printf("Read %zu pattern from %s\n", count, fname);
assert(pset_count(pattern_hash) == count);
return pattern_hash;
pattern_entry_t *entry;
pattern_entry_t **pattern_arr;
pattern_dumper_t *dump;
- int i, count = pset_count(status->pattern_hash);
+ size_t i, count = pset_count(status->pattern_hash);
- printf("\n%d pattern detected\n", count);
+ lc_printf("\n%zu pattern detected\n", count);
- if (count <= 0)
+ if (count == 0)
return;
/* creates a dumper */
/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
{
distrib_tbl_t *sum_tbl = (distrib_tbl_t*)env;
- stat_add_int_distrib_tbl(sum_tbl, PTR_TO_INT(entry->object), &entry->cnt);
+ stat_add_int_distrib_tbl(sum_tbl, (int)PTR_TO_INT(entry->object), &entry->cnt);
} /* add_distrib_entry */
/**
/* effects of optimizations */
if (dump_opts) {
- size_t i;
+ int i;
simple_dump_real_func_calls(dmp, &entry->cnt[gcnt_acc_real_func_call]);
simple_dump_tail_recursion(dmp, entry->num_tail_recursion);