コード例 #1
0
ファイル: irbackedge.c プロジェクト: lu-zero/libfirm
void clear_backedges(ir_node *n)
{
	bitset_t *ba = get_backarray(n);
	if (ba != NULL) {
		bitset_clear_all(ba);
	}
}
コード例 #2
0
ファイル: bitset.c プロジェクト: etosha/fslib
struct _bitset * bitset_create(int nbits) {
    struct _bitset * bitset;

    bitset = malloc(sizeof(struct _bitset));
    bitset->n_words = (nbits / WORD_SIZE + 1);
    bitset->words = malloc(sizeof(*bitset->words) * bitset->n_words);
    bitset_clear_all(bitset);

    return bitset;
}
コード例 #3
0
/**
 * @brief Initializes a new bitset data structure.
 * @details Initializes a bitset so that it can contain values from the range `[0, num_values - 1]`.
 * @param set Pointer to an unitialized bitset data structure.
 * @param num_values Number of values the set can store.
 * @remark Allocates O(`num_values`) memory.
 */
void bitset_init(bitset_t *set, bitset_index_t num_values)
{
#ifdef BITSET_ASSERTIONS
    assert(set);
#endif

    set->max = num_values;
    set->bits = (bitset_data_t *) malloc(sizeof(bitset_data_t) * BITSET_NUM_DATA_ELEMENTS(num_values));
    if(set->bits == NULL)
    {
        fprintf(stderr, "[bitset] Error: could not allocate memory to store bitset data\n");
        exit(0);
    }
    
    bitset_clear_all(set);
}
コード例 #4
0
ファイル: setreductions.c プロジェクト: jkeiren/muCRL
void set2_reduce_strong(lts_t lts){
	int *map,count,*newmap,i,*tmp,iter,setcount,j,set;
	bitset_t has_repr;

	has_repr=bitset_create(8,16);
	lts_uniq(lts);
	lts_sort(lts);
	lts_set_type(lts,LTS_BLOCK);
	map=(int*)malloc(sizeof(int)*lts->states);
	newmap=(int*)malloc(sizeof(int)*lts->states);
	if (!map || !newmap || !has_repr) Fatal(1,1,"out of memory");
	for(i=0;i<lts->states;i++){
		map[i]=0;
	}
	count=1;
	iter=0;
	for(;;){
		SetClear(-1);
		iter++;
		setcount=0;
		for(i=0;i<lts->states;i++){
			set=EMPTY_SET;
			for(j=lts->begin[i];j<lts->begin[i+1];j++){
				set=SetInsert(set,lts->label[j],map[lts->dest[j]]);
			}
			newmap[i]=set;
			if (!bitset_test(has_repr,set)){
				bitset_set(has_repr,set);
				setcount++;
			}
		}
		Warning(2,"count is %d",setcount);
		if(count==setcount) break;
		bitset_clear_all(has_repr);
		count=setcount;
		tmp=map;
		map=newmap;
		newmap=tmp;
	}
	setcount=0;
	for(i=0;i<lts->states;i++){
		newmap[i]=SetGetTag(map[i]);
		if (newmap[i]<0) {
			SetSetTag(map[i],setcount);
			newmap[i]=setcount;
			setcount++;
		}
	}
	free(map);
	map=newmap;
	Warning(2,"final count is %d",setcount);
	SetFree();
	lts_set_type(lts,LTS_LIST);
	lts->root=map[lts->root];
        lts->root2=map[lts->root2];
	for(i=0;i<lts->transitions;i++){
		lts->src[i]=map[lts->src[i]];
		lts->dest[i]=map[lts->dest[i]];
	}
	lts->states=count;
	lts_uniq(lts);
	free(map);
	bitset_destroy(has_repr);
	Warning(1,"reduction took %d iterations",iter);
}