Compare commits

..
Author SHA1 Message Date
Paul Eggert 5b8dfa1d7a Import of GCC head 2002-10-11 2002-10-13 04:42:59 +00:00
Paul Eggert 835cbc3d42 Import of GCC head 2002-10-11 2002-10-13 04:40:03 +00:00
19 changed files with 567 additions and 656 deletions
+10 -15
View File
@@ -1,10 +1,10 @@
/* Array bitsets.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,13 +13,9 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <config.h>
#include "abitset.h"
#include <stddef.h>
@@ -34,14 +30,13 @@
static bitset_bindex
abitset_resize (bitset src ATTRIBUTE_UNUSED,
bitset_bindex size ATTRIBUTE_UNUSED)
abitset_resize (bitset src, bitset_bindex size)
{
if (BITSET_SIZE_ (src) == size)
return size;
/* These bitsets have a fixed size. */
abort ();
if (BITSET_SIZE_ (src) != size)
abort ();
return size;
}
/* Find list of up to NUM bits set in BSET starting from and including
+14 -15
View File
@@ -1,28 +1,27 @@
/* Functions to support abitsets.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _ABITSET_H
#define _ABITSET_H
#define _ABITSET_H
#include "bitset.h"
extern size_t abitset_bytes PARAMS ((bitset_bindex));
extern size_t abitset_bytes (bitset_bindex);
extern bitset abitset_init PARAMS ((bitset, bitset_bindex));
extern bitset abitset_init (bitset, bitset_bindex);
#endif
+63 -66
View File
@@ -1,30 +1,28 @@
/* Base bitset stuff.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _BBITSET_H
#define _BBITSET_H
#include "config.h"
#include "libiberty.h"
#include <stdbool.h>
#include <limits.h>
#include <sys/types.h>
#include <stddef.h>
/* Currently we support five flavours of bitsets:
BITSET_ARRAY: Array of bits (fixed size, fast for dense bitsets).
@@ -35,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
BITSET_TABLE: Expandable table of pointers to arrays of bits
(variable size, less storage for large sparse sets).
Faster than BITSET_LIST for random access.
BITSET_VARRAY: Variable array of bits (variable size, fast for
BITSET_VARRAY: Variable array of bits (variable size, fast for
dense bitsets).
BITSET_STATS: Wrapper bitset for internal use only. Used for gathering
statistics and/or better run-time checking.
@@ -49,8 +47,8 @@ extern const char * const bitset_type_names[];
enum bitset_alloc_type {BITSET_MALLOC, BITSET_OBALLOC};
/* Data type used to store a word of bits. */
typedef unsigned long bitset_word;
#define BITSET_WORD_BITS ((unsigned) (CHAR_BIT * sizeof (bitset_word)))
typedef unsigned long int bitset_word;
#define BITSET_WORD_BITS ((unsigned int) (CHAR_BIT * sizeof (bitset_word)))
/* Bit index. In theory we might need a type wider than size_t, but
in practice we lose at most a factor of CHAR_BIT by going with
@@ -112,46 +110,45 @@ typedef union bitset_union *bitset;
/* The contents of this structure should be considered private. */
struct bitset_vtable
{
void (*set) PARAMS ((bitset, bitset_bindex));
void (*reset) PARAMS ((bitset, bitset_bindex));
bool (*toggle) PARAMS ((bitset, bitset_bindex));
bool (*test) PARAMS ((bitset, bitset_bindex));
bitset_bindex (*resize) PARAMS ((bitset, bitset_bindex));
bitset_bindex (*size) PARAMS ((bitset));
bitset_bindex (*count) PARAMS ((bitset));
void (*set) (bitset, bitset_bindex);
void (*reset) (bitset, bitset_bindex);
bool (*toggle) (bitset, bitset_bindex);
bool (*test) (bitset, bitset_bindex);
bitset_bindex (*resize) (bitset, bitset_bindex);
bitset_bindex (*size) (bitset);
bitset_bindex (*count) (bitset);
bool (*empty_p) PARAMS ((bitset));
void (*ones) PARAMS ((bitset));
void (*zero) PARAMS ((bitset));
bool (*empty_p) (bitset);
void (*ones) (bitset);
void (*zero) (bitset);
void (*copy) PARAMS ((bitset, bitset));
bool (*disjoint_p) PARAMS ((bitset, bitset));
bool (*equal_p) PARAMS ((bitset, bitset));
void (*not) PARAMS ((bitset, bitset));
bool (*subset_p) PARAMS ((bitset, bitset));
void (*copy) (bitset, bitset);
bool (*disjoint_p) (bitset, bitset);
bool (*equal_p) (bitset, bitset);
void (*not_) (bitset, bitset);
bool (*subset_p) (bitset, bitset);
void (*and) PARAMS ((bitset, bitset, bitset));
bool (*and_cmp) PARAMS ((bitset, bitset, bitset));
void (*andn) PARAMS ((bitset, bitset, bitset));
bool (*andn_cmp) PARAMS ((bitset, bitset, bitset));
void (*or) PARAMS ((bitset, bitset, bitset));
bool (*or_cmp) PARAMS ((bitset, bitset, bitset));
void (*xor) PARAMS ((bitset, bitset, bitset));
bool (*xor_cmp) PARAMS ((bitset, bitset, bitset));
void (*and_) (bitset, bitset, bitset);
bool (*and_cmp) (bitset, bitset, bitset);
void (*andn) (bitset, bitset, bitset);
bool (*andn_cmp) (bitset, bitset, bitset);
void (*or_) (bitset, bitset, bitset);
bool (*or_cmp) (bitset, bitset, bitset);
void (*xor_) (bitset, bitset, bitset);
bool (*xor_cmp) (bitset, bitset, bitset);
void (*and_or) PARAMS ((bitset, bitset, bitset, bitset));
bool (*and_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
void (*andn_or) PARAMS ((bitset, bitset, bitset, bitset));
bool (*andn_or_cmp) PARAMS ((bitset, bitset, bitset, bitset));
void (*or_and) PARAMS ((bitset, bitset, bitset, bitset));
bool (*or_and_cmp) PARAMS ((bitset, bitset, bitset, bitset));
void (*and_or) (bitset, bitset, bitset, bitset);
bool (*and_or_cmp) (bitset, bitset, bitset, bitset);
void (*andn_or) (bitset, bitset, bitset, bitset);
bool (*andn_or_cmp) (bitset, bitset, bitset, bitset);
void (*or_and) (bitset, bitset, bitset, bitset);
bool (*or_and_cmp) (bitset, bitset, bitset, bitset);
bitset_bindex (*list) PARAMS ((bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *));
bitset_bindex (*list_reverse) PARAMS ((bitset,
bitset_bindex *, bitset_bindex,
bitset_bindex *));
void (*free) PARAMS ((bitset));
bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
bitset_bindex *);
bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
bitset_bindex *);
void (*free) (bitset);
enum bitset_type type;
};
@@ -220,14 +217,14 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
#define BITSET_EQUAL_P_(DST, SRC) (SRC)->b.vtable->equal_p (DST, SRC)
/* DST = ~SRC. */
#define BITSET_NOT_(DST, SRC) (SRC)->b.vtable->not (DST, SRC)
#define BITSET_NOT_(DST, SRC) (SRC)->b.vtable->not_ (DST, SRC)
/* Return DST == DST | SRC. */
#define BITSET_SUBSET_P_(DST, SRC) (SRC)->b.vtable->subset_p (DST, SRC)
/* DST = SRC1 & SRC2. */
#define BITSET_AND_(DST, SRC1, SRC2) (SRC1)->b.vtable->and (DST, SRC1, SRC2)
#define BITSET_AND_(DST, SRC1, SRC2) (SRC1)->b.vtable->and_ (DST, SRC1, SRC2)
#define BITSET_AND_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->and_cmp (DST, SRC1, SRC2)
/* DST = SRC1 & ~SRC2. */
@@ -235,11 +232,11 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
#define BITSET_ANDN_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->andn_cmp (DST, SRC1, SRC2)
/* DST = SRC1 | SRC2. */
#define BITSET_OR_(DST, SRC1, SRC2) (SRC1)->b.vtable->or (DST, SRC1, SRC2)
#define BITSET_OR_(DST, SRC1, SRC2) (SRC1)->b.vtable->or_ (DST, SRC1, SRC2)
#define BITSET_OR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->or_cmp (DST, SRC1, SRC2)
/* DST = SRC1 ^ SRC2. */
#define BITSET_XOR_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor (DST, SRC1, SRC2)
#define BITSET_XOR_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor_ (DST, SRC1, SRC2)
#define BITSET_XOR_CMP_(DST, SRC1, SRC2) (SRC1)->b.vtable->xor_cmp (DST, SRC1, SRC2)
@@ -281,24 +278,24 @@ if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
/* Private functions for bitset implementations. */
extern bool bitset_toggle_ PARAMS ((bitset, bitset_bindex));
extern bool bitset_toggle_ (bitset, bitset_bindex);
extern bitset_bindex bitset_count_ PARAMS ((bitset));
extern bitset_bindex bitset_count_ (bitset);
extern bitset_bindex bitset_size_ PARAMS ((bitset));
extern bitset_bindex bitset_size_ (bitset);
extern bool bitset_copy_ PARAMS ((bitset, bitset));
extern bool bitset_copy_ (bitset, bitset);
extern void bitset_and_or_ PARAMS ((bitset, bitset, bitset, bitset));
extern void bitset_and_or_ (bitset, bitset, bitset, bitset);
extern bool bitset_and_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern bool bitset_and_or_cmp_ (bitset, bitset, bitset, bitset);
extern void bitset_andn_or_ PARAMS ((bitset, bitset, bitset, bitset));
extern void bitset_andn_or_ (bitset, bitset, bitset, bitset);
extern bool bitset_andn_or_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern bool bitset_andn_or_cmp_ (bitset, bitset, bitset, bitset);
extern void bitset_or_and_ PARAMS ((bitset, bitset, bitset, bitset));
extern void bitset_or_and_ (bitset, bitset, bitset, bitset);
extern bool bitset_or_and_cmp_ PARAMS ((bitset, bitset, bitset, bitset));
extern bool bitset_or_and_cmp_ (bitset, bitset, bitset, bitset);
#endif /* _BBITSET_H */
+20 -22
View File
@@ -1,10 +1,10 @@
/* General bitsets.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,16 +13,14 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <config.h>
#include "bitset.h"
#include <stdlib.h>
#include <string.h>
#include "bitset.h"
#include "abitset.h"
#include "lbitset.h"
#include "ebitset.h"
@@ -45,6 +43,9 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
switch (type)
{
default:
abort ();
case BITSET_ARRAY:
bytes = abitset_bytes (n_bits);
break;
@@ -60,9 +61,6 @@ bitset_bytes (enum bitset_type type, bitset_bindex n_bits)
case BITSET_VARRAY:
bytes = vbitset_bytes (n_bits);
break;
default:
abort ();
}
return bytes;
@@ -78,6 +76,9 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
switch (type)
{
default:
abort ();
case BITSET_ARRAY:
return abitset_init (bset, n_bits);
@@ -89,9 +90,6 @@ bitset_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
case BITSET_VARRAY:
return vbitset_init (bset, n_bits);
default:
abort ();
}
}
@@ -111,7 +109,7 @@ bitset_type_choose (bitset_bindex n_bits ATTRIBUTE_UNUSED, unsigned int attr)
/* Choose the type of bitset. Note that sometimes we will be asked
for a zero length fixed size bitset. */
/* If no attributes selected, choose a good compromise. */
if (!attr)
return BITSET_VARRAY;
@@ -138,7 +136,7 @@ bitset_alloc (bitset_bindex n_bits, enum bitset_type type)
bytes = bitset_bytes (type, n_bits);
bset = (bitset) xcalloc (1, bytes);
bset = xcalloc (1, bytes);
/* The cache is disabled until some elements are allocated. If we
have variable length arrays, then we may need to allocate a dummy
@@ -296,7 +294,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
if (verbose)
fprintf (file, "n_bits = %lu, set = {",
(unsigned long) bitset_size (bset));
(unsigned long int) bitset_size (bset));
pos = 30;
BITSET_FOR_EACH (iter, bset, i, 0)
@@ -307,7 +305,7 @@ bitset_print (FILE *file, bitset bset, bool verbose)
pos = 0;
}
fprintf (file, "%d ", i);
fprintf (file, "%lu ", (unsigned long int) i);
pos += 1 + (i >= 10) + (i >= 100);
};
@@ -421,6 +419,9 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
switch (op)
{
default:
abort ();
case BITSET_OP_OR_AND:
bitset_or (tmp, src1, src2);
changed = bitset_and_cmp (dst, src3, tmp);
@@ -435,9 +436,6 @@ bitset_op4_cmp (bitset dst, bitset src1, bitset src2, bitset src3,
bitset_andn (tmp, src1, src2);
changed = bitset_or_cmp (dst, src3, tmp);
break;
default:
abort ();
}
bitset_free (tmp);
+52 -62
View File
@@ -1,20 +1,19 @@
/* Generic bitsets.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _BITSET_H
#define _BITSET_H
@@ -23,19 +22,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
Only use the functions and macros defined in this file. */
#include "bbitset.h"
/* obstack.h tries to be portable to K&R compilers, but its
__INT_TO_PTR macro generates diagnostics on compilers like Tru64 cc
that define __STDC__ to 0 when not in strict ANSI mode. The bitset
code assumes C89 or later, so it can avoid these glitches by
defining __INT_TO_PTR appropriately for C89 or later. */
#ifndef __INT_TO_PTR
# define __INT_TO_PTR(P) ((void *) ((P) + (char *) 0))
#endif
#include "obstack.h"
#include <stdio.h>
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#endif
/* Attributes used to select a bitset implementation. */
enum bitset_attr {BITSET_FIXED = 1, /* Bitset size fixed. */
BITSET_VARIABLE = 2, /* Bitset size variable. */
@@ -103,38 +96,37 @@ typedef struct
/* Return bytes required for bitset of desired type and size. */
extern size_t bitset_bytes PARAMS ((enum bitset_type, bitset_bindex));
extern size_t bitset_bytes (enum bitset_type, bitset_bindex);
/* Initialise a bitset with desired type and size. */
extern bitset bitset_init PARAMS ((bitset, bitset_bindex, enum bitset_type));
extern bitset bitset_init (bitset, bitset_bindex, enum bitset_type);
/* Select an implementation type based on the desired bitset size
and attributes. */
extern enum bitset_type bitset_type_choose PARAMS ((bitset_bindex,
bitset_attrs));
extern enum bitset_type bitset_type_choose (bitset_bindex, bitset_attrs);
/* Create a bitset of desired type and size. The bitset is zeroed. */
extern bitset bitset_alloc PARAMS ((bitset_bindex, enum bitset_type));
extern bitset bitset_alloc (bitset_bindex, enum bitset_type);
/* Free bitset. */
extern void bitset_free PARAMS ((bitset));
extern void bitset_free (bitset);
/* Create a bitset of desired type and size using an obstack. The
bitset is zeroed. */
extern bitset bitset_obstack_alloc PARAMS ((struct obstack *bobstack,
bitset_bindex, enum bitset_type));
extern bitset bitset_obstack_alloc (struct obstack *bobstack,
bitset_bindex, enum bitset_type);
/* Free bitset allocated on obstack. */
extern void bitset_obstack_free PARAMS ((bitset));
extern void bitset_obstack_free (bitset);
/* Create a bitset of desired size and attributes. The bitset is zeroed. */
extern bitset bitset_create PARAMS ((bitset_bindex, bitset_attrs));
extern bitset bitset_create (bitset_bindex, bitset_attrs);
/* Return bitset type. */
extern enum bitset_type bitset_type_get PARAMS ((bitset));
extern enum bitset_type bitset_type_get (bitset);
/* Return bitset type name. */
extern const char *bitset_type_name_get PARAMS ((bitset));
extern const char *bitset_type_name_get (bitset);
/* Set bit BITNO in bitset BSET. */
@@ -186,7 +178,7 @@ bitset_test (bitset bset, bitset_bindex bitno)
#define bitset_size(SRC) BITSET_SIZE_ (SRC)
/* Change size of bitset. */
extern void bitset_resize PARAMS ((bitset, bitset_bindex));
extern void bitset_resize (bitset, bitset_bindex);
/* Return number of bits set in bitset SRC. */
#define bitset_count(SRC) BITSET_COUNT_ (SRC)
@@ -286,43 +278,42 @@ extern void bitset_resize PARAMS ((bitset, bitset_bindex));
BITSET_LIST_REVERSE_ (BSET, LIST, NUM, NEXT)
/* Return true if both bitsets are of the same type and size. */
extern bool
bitset_compatible_p (bitset bset1, bitset bset2);
extern bool bitset_compatible_p (bitset bset1, bitset bset2);
/* Find next set bit from the given bit index. */
extern bitset_bindex bitset_next PARAMS ((bitset, bitset_bindex));
extern bitset_bindex bitset_next (bitset, bitset_bindex);
/* Find previous set bit from the given bit index. */
extern bitset_bindex bitset_prev PARAMS ((bitset, bitset_bindex));
extern bitset_bindex bitset_prev (bitset, bitset_bindex);
/* Find first set bit. */
extern bitset_bindex bitset_first PARAMS ((bitset));
extern bitset_bindex bitset_first (bitset);
/* Find last set bit. */
extern bitset_bindex bitset_last PARAMS ((bitset));
extern bitset_bindex bitset_last (bitset);
/* Return nonzero if this is the only set bit. */
extern bool bitset_only_set_p PARAMS ((bitset, bitset_bindex));
extern bool bitset_only_set_p (bitset, bitset_bindex);
/* Dump bitset. */
extern void bitset_dump PARAMS ((FILE *, bitset));
extern void bitset_dump (FILE *, bitset);
/* Loop over all elements of BSET, starting with MIN, setting INDEX
to the index of each set bit. For example, the following will print
the bits set in a bitset:
bitset_bindex index;
bitset_bindex i;
bitset_iterator iter;
BITSET_FOR_EACH (iter, src, index, 0)
BITSET_FOR_EACH (iter, src, i, 0)
{
printf ("%ld ", index);
printf ("%lu ", (unsigned long int) i);
};
*/
#define BITSET_FOR_EACH(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list (BSET, ITER.list, \
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
for (ITER.i = 0; \
ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
@@ -330,20 +321,20 @@ extern void bitset_dump PARAMS ((FILE *, bitset));
/* Loop over all elements of BSET, in reverse order starting with
MIN, setting INDEX to the index of each set bit. For example, the
MIN, setting INDEX to the index of each set bit. For example, the
following will print the bits set in a bitset in reverse order:
bitset_bindex index;
bitset_bindex i;
bitset_iterator iter;
BITSET_FOR_EACH_REVERSE (iter, src, index, 0)
BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
{
printf ("%ld ", index);
printf ("%lu ", (unsigned long int) i);
};
*/
#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
(ITER.num == BITSET_LIST_SIZE) \
(ITER.num == BITSET_LIST_SIZE) \
&& (ITER.num = bitset_list_reverse (BSET, ITER.list, \
BITSET_LIST_SIZE, &ITER.next));) \
for (ITER.i = 0; \
@@ -374,28 +365,27 @@ extern void bitset_dump PARAMS ((FILE *, bitset));
/* Release any memory tied up with bitsets. */
extern void bitset_release_memory PARAMS ((void));
extern void bitset_release_memory (void);
/* Enable bitset stats gathering. */
extern void bitset_stats_enable PARAMS ((void));
extern void bitset_stats_enable (void);
/* Disable bitset stats gathering. */
extern void bitset_stats_disable PARAMS ((void));
extern void bitset_stats_disable (void);
/* Read bitset stats file of accummulated stats. */
void bitset_stats_read PARAMS ((const char *filename));
void bitset_stats_read (const char *file_name);
/* Write bitset stats file of accummulated stats. */
void bitset_stats_write PARAMS ((const char *filename));
void bitset_stats_write (const char *file_name);
/* Dump bitset stats. */
extern void bitset_stats_dump PARAMS ((FILE *));
extern void bitset_stats_dump (FILE *);
/* Function to debug bitset from debugger. */
extern void debug_bitset PARAMS ((bitset));
extern void debug_bitset (bitset);
/* Function to debug bitset stats from debugger. */
extern void debug_bitset_stats PARAMS ((void));
extern void debug_bitset_stats (void);
#endif /* _BITSET_H */
+37 -45
View File
@@ -1,10 +1,10 @@
/* Bitset statistics.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,38 +13,30 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This file is a wrapper bitset implementation for the other bitset
implementations. It provides bitset compatibility checking and
statistics gathering without having to instrument the bitset
implementations. When statistics gathering is enabled, the bitset
operations get vectored through here and we then call the appropriate
routines.
*/
routines. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <config.h>
#include "bitset_stats.h"
#include "bbitset.h"
#include "abitset.h"
#include "ebitset.h"
#include "lbitset.h"
#include "vbitset.h"
#include "bitset_stats.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef HAVE_GETTEXT_H
#include "gettext.h"
#define _(Msgid) gettext (Msgid)
#else
#define _(Msgid) Msgid
#endif
/* Configuration macros. */
#define BITSET_STATS_FILE "bitset.dat"
@@ -54,29 +46,29 @@
/* Accessor macros. */
#define BITSET_STATS_ALLOCS_INC(TYPE) \
#define BITSET_STATS_ALLOCS_INC(TYPE) \
bitset_stats_info->types[(TYPE)].allocs++
#define BITSET_STATS_FREES_INC(BSET) \
#define BITSET_STATS_FREES_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].frees++
#define BITSET_STATS_SETS_INC(BSET) \
#define BITSET_STATS_SETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].sets++
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
#define BITSET_STATS_CACHE_SETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_sets++
#define BITSET_STATS_RESETS_INC(BSET) \
#define BITSET_STATS_RESETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].resets++
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
#define BITSET_STATS_CACHE_RESETS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_resets++
#define BITSET_STATS_TESTS_INC(BSET) \
#define BITSET_STATS_TESTS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].tests++
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
#define BITSET_STATS_CACHE_TESTS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].cache_tests++
#define BITSET_STATS_LISTS_INC(BSET) \
#define BITSET_STATS_LISTS_INC(BSET) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].lists++
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
#define BITSET_STATS_LIST_COUNTS_INC(BSET, I) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_counts[(I)]++
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
#define BITSET_STATS_LIST_SIZES_INC(BSET, I) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_sizes[(I)]++
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
#define BITSET_STATS_LIST_DENSITY_INC(BSET, I) \
bitset_stats_info->types[BITSET_TYPE_ (BSET)].list_density[(I)]++
@@ -164,8 +156,8 @@ bitset_log_histogram_print (FILE *file, const char *name, const char *msg,
for (; i < n_bins; i++)
fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n",
max_width - ((unsigned int) (0.30103 * (i) + 0.9999) + 1),
(unsigned long) 1 << (i - 1),
((unsigned long) 1 << i) - 1,
1UL << (i - 1),
(1UL << i) - 1,
bins[i],
(100.0 * bins[i]) / total);
}
@@ -245,17 +237,17 @@ bitset_stats_disable (void)
/* Read bitset statistics file. */
void
bitset_stats_read (const char *filename)
bitset_stats_read (const char *file_name)
{
FILE *file;
if (!bitset_stats_info)
return;
if (!filename)
filename = BITSET_STATS_FILE;
if (!file_name)
file_name = BITSET_STATS_FILE;
file = fopen (filename, "r");
file = fopen (file_name, "r");
if (file)
{
if (fread (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
@@ -275,17 +267,17 @@ bitset_stats_read (const char *filename)
/* Write bitset statistics file. */
void
bitset_stats_write (const char *filename)
bitset_stats_write (const char *file_name)
{
FILE *file;
if (!bitset_stats_info)
return;
if (!filename)
filename = BITSET_STATS_FILE;
if (!file_name)
file_name = BITSET_STATS_FILE;
file = fopen (filename, "w");
file = fopen (file_name, "w");
if (file)
{
if (fwrite (&bitset_stats_info_data, sizeof (bitset_stats_info_data),
@@ -700,32 +692,32 @@ bitset_stats_init (bitset bset, bitset_bindex n_bits, enum bitset_type type)
we are a wrapper over. */
switch (type)
{
default:
abort ();
case BITSET_ARRAY:
bytes = abitset_bytes (n_bits);
sbset = (bitset) xcalloc (1, bytes);
sbset = xcalloc (1, bytes);
abitset_init (sbset, n_bits);
break;
case BITSET_LIST:
bytes = lbitset_bytes (n_bits);
sbset = (bitset) xcalloc (1, bytes);
sbset = xcalloc (1, bytes);
lbitset_init (sbset, n_bits);
break;
case BITSET_TABLE:
bytes = ebitset_bytes (n_bits);
sbset = (bitset) xcalloc (1, bytes);
sbset = xcalloc (1, bytes);
ebitset_init (sbset, n_bits);
break;
case BITSET_VARRAY:
bytes = vbitset_bytes (n_bits);
sbset = (bitset) xcalloc (1, bytes);
sbset = xcalloc (1, bytes);
vbitset_init (sbset, n_bits);
break;
default:
abort ();
}
bset->s.bset = sbset;
+14 -16
View File
@@ -1,20 +1,19 @@
/* Functions to support bitset statistics.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _BITSET_STATS_H
#define _BITSET_STATS_H
@@ -23,11 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
extern bool bitset_stats_enabled;
extern enum bitset_type bitset_stats_type_get PARAMS ((bitset));
extern enum bitset_type bitset_stats_type_get (bitset);
extern size_t bitset_stats_bytes PARAMS ((void));
extern size_t bitset_stats_bytes (void);
extern bitset bitset_stats_init PARAMS ((bitset, bitset_bindex,
enum bitset_type));
extern bitset bitset_stats_init (bitset, bitset_bindex, enum bitset_type);
#endif
+16 -21
View File
@@ -1,29 +1,24 @@
/* Bitset vectors.
Copyright (C) 2001, 2002 Free Software Foundation, Inc.
Copyright (C) 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GCC.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include <config.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "bitsetv.h"
#include <stdlib.h>
#include "bitsetv.h"
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
@@ -47,7 +42,7 @@ bitsetv_alloc (bitset_bindex n_vecs, bitset_bindex n_bits,
/* Allocate vector table at head of bitset array. */
vector_bytes = (n_vecs + 1) * sizeof (bitset) + bytes - 1;
vector_bytes -= vector_bytes % bytes;
bsetv = (bitset *) xcalloc (1, vector_bytes + bytes * n_vecs);
bsetv = xcalloc (1, vector_bytes + bytes * n_vecs);
for (i = 0; i < n_vecs; i++)
{
@@ -149,7 +144,7 @@ bitsetv_dump (FILE *file, char const *title, char const *subtitle,
fprintf (file, "%s\n", title);
for (i = 0; bsetv[i]; i++)
{
fprintf (file, "%s %lu\n", subtitle, (unsigned long) i);
fprintf (file, "%s %lu\n", subtitle, (unsigned long int) i);
bitset_dump (file, bsetv[i]);
}
@@ -164,7 +159,7 @@ debug_bitsetv (bitsetv bsetv)
for (i = 0; bsetv[i]; i++)
{
fprintf (stderr, "%lu: ", (unsigned long) i);
fprintf (stderr, "%lu: ", (unsigned long int) i);
debug_bitset (bsetv[i]);
}
+20 -24
View File
@@ -1,20 +1,19 @@
/* Bitset vectors.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _BITSETV_H
#define _BITSETV_H
@@ -25,38 +24,35 @@ typedef bitset * bitsetv;
/* Create a vector of N_VECS bitsets, each of N_BITS, and of
type TYPE. */
extern bitsetv bitsetv_alloc PARAMS ((bitset_bindex, bitset_bindex,
enum bitset_type));
extern bitsetv bitsetv_alloc (bitset_bindex, bitset_bindex, enum bitset_type);
/* Create a vector of N_VECS bitsets, each of N_BITS, and with
attribute hints specified by ATTR. */
extern bitsetv bitsetv_create PARAMS ((bitset_bindex, bitset_bindex,
unsigned int));
extern bitsetv bitsetv_create (bitset_bindex, bitset_bindex, unsigned int);
/* Free vector of bitsets. */
extern void bitsetv_free PARAMS ((bitsetv));
extern void bitsetv_free (bitsetv);
/* Zero vector of bitsets. */
extern void bitsetv_zero PARAMS ((bitsetv));
extern void bitsetv_zero (bitsetv);
/* Set vector of bitsets. */
extern void bitsetv_ones PARAMS ((bitsetv));
extern void bitsetv_ones (bitsetv);
/* Given a vector BSETV of N bitsets of size N, modify its contents to
be the transitive closure of what was given. */
extern void bitsetv_transitive_closure PARAMS ((bitsetv));
extern void bitsetv_transitive_closure (bitsetv);
/* Given a vector BSETV of N bitsets of size N, modify its contents to
be the reflexive transitive closure of what was given. This is
the same as transitive closure but with all bits on the diagonal
of the bit matrix set. */
extern void bitsetv_reflexive_transitive_closure PARAMS ((bitsetv));
extern void bitsetv_reflexive_transitive_closure (bitsetv);
/* Dump vector of bitsets. */
extern void bitsetv_dump PARAMS ((FILE *, const char *,
const char *, bitsetv));
extern void bitsetv_dump (FILE *, const char *, const char *, bitsetv);
/* Function to debug vector of bitsets from debugger. */
extern void debug_bitsetv PARAMS ((bitsetv));
extern void debug_bitsetv (bitsetv);
#endif /* _BITSETV_H */
+28 -36
View File
@@ -1,10 +1,10 @@
/* Functions to support expandable bitsets.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,15 +13,12 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <config.h>
#include "ebitset.h"
#include "obstack.h"
#include <stdlib.h>
#include <string.h>
@@ -52,7 +49,7 @@
/* Number of bits stored in each element. */
#define EBITSET_ELT_BITS \
((unsigned) (EBITSET_ELT_WORDS * BITSET_WORD_BITS))
((unsigned int) (EBITSET_ELT_WORDS * BITSET_WORD_BITS))
/* Ebitset element. We use an array of bits. */
typedef struct ebitset_elt_struct
@@ -115,15 +112,13 @@ static ebitset_elt *ebitset_free_list; /* Free list of bitset elements. */
((BSET)->b.cindex = (EINDEX) * EBITSET_ELT_WORDS, \
(BSET)->b.cdata = EBITSET_WORDS (EBITSET_ELTS (BSET) [EINDEX]))
#undef min
#undef max
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
static bitset_bindex
ebitset_resize (src, n_bits)
bitset src;
bitset_bindex n_bits;
ebitset_resize (bitset src, bitset_bindex n_bits)
{
bitset_windex oldsize;
bitset_windex newsize;
@@ -138,7 +133,7 @@ ebitset_resize (src, n_bits)
{
bitset_windex size;
/* The bitset needs to grow. If we already have enough memory
/* The bitset needs to grow. If we already have enough memory
allocated, then just zero what we need. */
if (newsize > EBITSET_ASIZE (src))
{
@@ -151,13 +146,13 @@ ebitset_resize (src, n_bits)
size = newsize;
else
size = newsize + newsize / 4;
EBITSET_ELTS (src)
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
EBITSET_ASIZE (src) = size;
}
memset (EBITSET_ELTS (src) + oldsize, 0,
memset (EBITSET_ELTS (src) + oldsize, 0,
(newsize - oldsize) * sizeof (ebitset_elt *));
}
else
@@ -212,15 +207,13 @@ ebitset_elt_alloc (void)
#define OBSTACK_CHUNK_FREE free
#endif
#if !defined(__GNUC__) || (__GNUC__ < 2)
#if ! defined __GNUC__ || __GNUC__ < 2
#define __alignof__(type) 0
#endif
obstack_specify_allocation (&ebitset_obstack, OBSTACK_CHUNK_SIZE,
__alignof__ (ebitset_elt),
(void *(*)PARAMS ((long)))
OBSTACK_CHUNK_ALLOC,
(void (*)PARAMS ((void *)))
OBSTACK_CHUNK_FREE);
}
@@ -326,6 +319,9 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
switch (mode)
{
default:
abort ();
case EBITSET_FIND:
return 0;
@@ -341,9 +337,6 @@ ebitset_elt_find (bitset bset, bitset_bindex bindex,
case EBITSET_SUBST:
return &ebitset_zero_elts[0];
default:
abort ();
}
}
@@ -838,15 +831,14 @@ ebitset_list (bitset bset, bitset_bindex *list,
/* Ensure that any unused bits within the last element are clear. */
static inline void
ebitset_unused_clear (dst)
bitset dst;
ebitset_unused_clear (bitset dst)
{
unsigned int last_bit;
bitset_bindex n_bits;
n_bits = BITSET_NBITS_ (dst);
last_bit = n_bits % EBITSET_ELT_BITS;
if (last_bit)
{
bitset_windex eindex;
@@ -854,20 +846,20 @@ ebitset_unused_clear (dst)
ebitset_elt *elt;
elts = EBITSET_ELTS (dst);
eindex = n_bits / EBITSET_ELT_BITS;
elt = elts[eindex];
if (elt)
{
bitset_windex windex;
bitset_windex woffset;
bitset_word *srcp = EBITSET_WORDS (elt);
windex = n_bits / BITSET_WORD_BITS;
woffset = eindex * EBITSET_ELT_WORDS;
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
srcp[windex - woffset] &= ((bitset_word) 1 << last_bit) - 1;
windex++;
for (; (windex - woffset) < EBITSET_ELT_WORDS; windex++)
srcp[windex - woffset] = 0;
@@ -1095,6 +1087,9 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
dstp = EBITSET_WORDS (delt);
switch (op)
{
default:
abort ();
case BITSET_OP_OR:
for (i = 0; i < EBITSET_ELT_WORDS; i++, dstp++)
{
@@ -1146,9 +1141,6 @@ ebitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
}
}
break;
default:
abort ();
}
if (!ebitset_elt_zero_p (delt))
+15 -16
View File
@@ -1,30 +1,29 @@
/* Functions to support ebitsets.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _EBITSET_H
#define _EBITSET_H
#define _EBITSET_H
#include "bitset.h"
extern size_t ebitset_bytes PARAMS ((bitset_bindex));
extern size_t ebitset_bytes (bitset_bindex);
extern bitset ebitset_init PARAMS ((bitset, bitset_bindex));
extern bitset ebitset_init (bitset, bitset_bindex);
extern void ebitset_release_memory PARAMS ((void));
extern void ebitset_release_memory (void);
#endif
+22 -28
View File
@@ -1,10 +1,10 @@
/* Functions to support link list bitsets.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes ([email protected]).
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,15 +13,12 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <config.h>
#include "lbitset.h"
#include "obstack.h"
#include <stddef.h>
#include <stdlib.h>
@@ -41,7 +38,7 @@
/* Number of words to use for each element. The larger the value the
greater the size of the cache and the shorter the time to find a given bit
but the more memory wasted for sparse bitsets and the longer the time
to search for set bits.
to search for set bits.
The routines that dominate timing profiles are lbitset_elt_find
and lbitset_elt_link, especially when accessing the bits randomly. */
@@ -54,7 +51,7 @@ typedef bitset_word lbitset_word;
/* Number of bits stored in each element. */
#define LBITSET_ELT_BITS \
((unsigned) (LBITSET_ELT_WORDS * LBITSET_WORD_BITS))
((unsigned int) (LBITSET_ELT_WORDS * LBITSET_WORD_BITS))
/* Lbitset element. We use an array of bits for each element.
These are linked together in a doubly-linked list. */
@@ -78,7 +75,7 @@ static struct obstack lbitset_obstack;
static bool lbitset_obstack_init = false;
static lbitset_elt *lbitset_free_list; /* Free list of bitset elements. */
extern void debug_lbitset PARAMS ((bitset));
extern void debug_lbitset (bitset);
#define LBITSET_CURRENT1(X) \
((lbitset_elt *) (void *) ((char *) (X) - offsetof (lbitset_elt, words)))
@@ -121,15 +118,13 @@ lbitset_elt_alloc (void)
#define OBSTACK_CHUNK_FREE free
#endif
#if !defined(__GNUC__) || (__GNUC__ < 2)
#if ! defined __GNUC__ || __GNUC__ < 2
#define __alignof__(type) 0
#endif
obstack_specify_allocation (&lbitset_obstack, OBSTACK_CHUNK_SIZE,
__alignof__ (lbitset_elt),
(void *(*)PARAMS ((long)))
OBSTACK_CHUNK_ALLOC,
(void (*)PARAMS ((void *)))
OBSTACK_CHUNK_FREE);
}
@@ -365,6 +360,9 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
switch (mode)
{
default:
abort ();
case LBITSET_FIND:
return 0;
@@ -378,9 +376,6 @@ lbitset_elt_find (bitset bset, bitset_windex windex,
case LBITSET_SUBST:
return &lbitset_zero_elts[0];
default:
abort ();
}
}
@@ -883,26 +878,25 @@ lbitset_empty_p (bitset dst)
/* Ensure that any unused bits within the last element are clear. */
static inline void
lbitset_unused_clear (dst)
bitset dst;
lbitset_unused_clear (bitset dst)
{
unsigned int last_bit;
bitset_bindex n_bits;
n_bits = BITSET_SIZE_ (dst);
last_bit = n_bits % LBITSET_ELT_BITS;
if (last_bit)
{
lbitset_elt *elt;
bitset_windex windex;
bitset_word *srcp;
elt = LBITSET_TAIL (dst);
srcp = elt->words;
windex = n_bits / BITSET_WORD_BITS;
srcp[windex - elt->index] &= ((bitset_word) 1 << last_bit) - 1;
srcp[windex - elt->index] &= ((bitset_word) 1 << last_bit) - 1;
windex++;
for (; (windex - elt->index) < LBITSET_ELT_WORDS; windex++)
@@ -1120,6 +1114,9 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
dstp = dtmp->words;
switch (op)
{
default:
abort ();
case BITSET_OP_OR:
for (i = 0; i < LBITSET_ELT_WORDS; i++, dstp++)
{
@@ -1171,9 +1168,6 @@ lbitset_op3_cmp (bitset dst, bitset src1, bitset src2, enum bitset_ops op)
}
}
break;
default:
abort ();
}
if (!lbitset_elt_zero_p (dtmp))
@@ -1391,7 +1385,7 @@ debug_lbitset (bitset bset)
for (elt = LBITSET_HEAD (bset); elt; elt = elt->next)
{
fprintf (stderr, "Elt %lu\n", (unsigned long) elt->index);
fprintf (stderr, "Elt %lu\n", (unsigned long int) elt->index);
for (i = 0; i < LBITSET_ELT_WORDS; i++)
{
unsigned int j;
+15 -16
View File
@@ -1,30 +1,29 @@
/* Functions to support lbitsets.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _LBITSET_H
#define _LBITSET_H
#define _LBITSET_H
#include "bitset.h"
extern size_t lbitset_bytes PARAMS ((bitset_bindex));
extern size_t lbitset_bytes (bitset_bindex);
extern bitset lbitset_init PARAMS ((bitset, bitset_bindex));
extern bitset lbitset_init (bitset, bitset_bindex);
extern void lbitset_release_memory PARAMS ((void));
extern void lbitset_release_memory (void);
#endif
+30 -7
View File
@@ -1,12 +1,35 @@
/* Dummy libiberty header file. */
/* Fake libiberty.h for Bison.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
#define PARAMS(X) X
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
#define xmalloc malloc
#define xcalloc calloc
#define xrealloc realloc
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#define xalloc_die()
/* Bison depends on libiberty's implementation of bitsets, which
requires a `libiberty.h' file. This file provides the minimum
services. */
#ifndef BISON_LIBIBERTY_H_
# define BISON_LIBIBERTY_H_ 1
# ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
# define __attribute__(x)
# endif
# endif
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# include "xalloc.h"
#endif /* ! BISON_LIBIBERTY_H_ */
+35 -59
View File
@@ -1,43 +1,29 @@
/* Timing variables for measuring compiler performance.
Copyright (C) 2000, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2000 Free Software Foundation, Inc.
Contributed by Alex Samuel <samuel@codesourcery.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This file is part of GCC.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
#include <config.h>
#if IN_GCC
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include "config.h"
#include "system.h"
#include "intl.h"
#include "rtl.h"
#else
/* This source file is taken from the GCC source code, with slight
modifications that are under control of the IN_GCC preprocessor
variable. The !IN_GCC part of this file is specific to Bison. */
# include "../src/system.h"
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# endif
int timevar_report = 0;
#endif
#ifdef HAVE_SYS_TIMES_H
# include <sys/times.h>
#endif
@@ -60,13 +46,13 @@ struct tms
#endif
#if defined HAVE_DECL_GETRUSAGE && !HAVE_DECL_GETRUSAGE
extern int getrusage (int, struct rusage *);
extern int getrusage PARAMS ((int, struct rusage *));
#endif
#if defined HAVE_DECL_TIMES && !HAVE_DECL_TIMES
extern clock_t times (struct tms *);
extern clock_t times PARAMS ((struct tms *));
#endif
#if defined HAVE_DECL_CLOCK && !HAVE_DECL_CLOCK
extern clock_t clock (void);
extern clock_t clock PARAMS ((void));
#endif
#ifndef RUSAGE_SELF
@@ -115,23 +101,21 @@ extern clock_t clock (void);
_constants_ variable at run time, anyway? */
#ifdef USE_TIMES
static float ticks_to_msec;
#define TICKS_TO_MSEC (1.0 / TICKS_PER_SECOND)
#define TICKS_TO_MSEC (1 / (float)TICKS_PER_SECOND)
#endif
#ifdef USE_CLOCK
static float clocks_to_msec;
#define CLOCKS_TO_MSEC (1.0 / CLOCKS_PER_SEC)
#define CLOCKS_TO_MSEC (1 / (float)CLOCKS_PER_SEC)
#endif
#if IN_GCC
#include "flags.h"
#endif
#include "timevar.h"
/* See timevar.h for an explanation of timing variables. */
/* This macro evaluates to nonzero if timing variables are enabled. */
#define TIMEVAR_ENABLE (timevar_report)
#define TIMEVAR_ENABLE (time_report)
/* A timing variable. */
@@ -184,10 +168,11 @@ static struct timevar_stack_def *unused_stack_instances;
element. */
static struct timevar_time_def start_time;
static void get_time (struct timevar_time_def *);
static void timevar_accumulate (struct timevar_time_def *,
struct timevar_time_def *,
struct timevar_time_def *);
static void get_time
PARAMS ((struct timevar_time_def *));
static void timevar_accumulate
PARAMS ((struct timevar_time_def *, struct timevar_time_def *,
struct timevar_time_def *));
/* Fill the current times into TIME. The definition of this function
also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and
@@ -208,21 +193,12 @@ get_time (now)
#ifdef USE_TIMES
struct tms tms;
now->wall = times (&tms) * ticks_to_msec;
#if IN_GCC
now->user = tms.tms_utime * ticks_to_msec;
now->sys = tms.tms_stime * ticks_to_msec;
#else
now->user = (tms.tms_utime + tms.tms_cutime) * ticks_to_msec;
now->sys = (tms.tms_stime + tms.tms_cstime) * ticks_to_msec;
#endif
#endif
#ifdef USE_GETRUSAGE
struct rusage rusage;
#if IN_GCC
getrusage (RUSAGE_SELF, &rusage);
#else
getrusage (RUSAGE_CHILDREN, &rusage);
#endif
now->user = rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
now->sys = rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
#endif
@@ -232,17 +208,17 @@ get_time (now)
}
}
/* Add the difference between STOP and START to TIMER. */
/* Add the difference between STOP_TIME and START_TIME to TIMER. */
static void
timevar_accumulate (timer, start, stop)
timevar_accumulate (timer, start_time, stop_time)
struct timevar_time_def *timer;
struct timevar_time_def *start;
struct timevar_time_def *stop;
struct timevar_time_def *start_time;
struct timevar_time_def *stop_time;
{
timer->user += stop->user - start->user;
timer->sys += stop->sys - start->sys;
timer->wall += stop->wall - start->wall;
timer->user += stop_time->user - start_time->user;
timer->sys += stop_time->sys - start_time->sys;
timer->wall += stop_time->wall - start_time->wall;
}
/* Initialize timing variables. */
@@ -444,7 +420,7 @@ timevar_print (fp)
FILE *fp;
{
/* Only print stuff if we have some sort of time information. */
#if defined HAVE_USER_TIME || defined HAVE_SYS_TIME || defined HAVE_WALL_TIME
#if defined (HAVE_USER_TIME) || defined (HAVE_SYS_TIME) || defined (HAVE_WALL_TIME)
unsigned int /* timevar_id_t */ id;
struct timevar_time_def *total = &timevars[TV_TOTAL].elapsed;
struct timevar_time_def now;
@@ -485,7 +461,7 @@ timevar_print (fp)
continue;
/* Don't print timing variables if we're going to get a row of
zeroes. */
zeroes. */
if (tv->elapsed.user < tiny
&& tv->elapsed.sys < tiny
&& tv->elapsed.wall < tiny)
+64 -28
View File
@@ -1,22 +1,24 @@
/* This file contains the definitions for timing variables used to -*- C -*-
/* This file contains the definitions for timing variables used to
measure run-time performance of the compiler.
Copyright (C) 2002, 2007 Free Software Foundation, Inc.
Contributed by Akim Demaille <akim@freefriends.org>.
Copyright (C) 2000 Free Software Foundation, Inc.
Contributed by Alex Samuel <samuel@codesourcery.com>
This file is part of Bison, the GNU Compiler Compiler.
This file is part of GCC.
This program is free software: you can redistribute it and/or modify
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* This file contains timing variable definitions, used by timevar.h
and timevar.c.
@@ -31,25 +33,59 @@
/* The total execution time. */
DEFTIMEVAR (TV_TOTAL , "total time")
/* Time spent in the reader. */
DEFTIMEVAR (TV_READER , "reader")
DEFTIMEVAR (TV_SCANNING , "scanner")
DEFTIMEVAR (TV_PARSING , "parser")
/* Time spent garbage-collecting. */
DEFTIMEVAR (TV_GC , "garbage collection")
/* Time spent handling the grammar. */
DEFTIMEVAR (TV_REDUCE , "reducing the grammar")
DEFTIMEVAR (TV_SETS , "computing the sets")
DEFTIMEVAR (TV_LR0 , "LR(0)")
DEFTIMEVAR (TV_LALR , "LALR(1)")
DEFTIMEVAR (TV_CONFLICTS , "conflicts")
/* Time spent generating dump files. */
DEFTIMEVAR (TV_DUMP , "dump files")
/* Time spent outputing results. */
DEFTIMEVAR (TV_REPORT , "outputing report")
DEFTIMEVAR (TV_GRAPH , "outputing graph")
DEFTIMEVAR (TV_XML , "outputing xml")
DEFTIMEVAR (TV_ACTIONS , "parser action tables")
DEFTIMEVAR (TV_PARSER , "outputing parser")
DEFTIMEVAR (TV_M4 , "running m4")
/* Time spent by constructing CFG. */
DEFTIMEVAR (TV_CFG , "cfg construction")
/* Time spent by cleaning up CFG. */
DEFTIMEVAR (TV_CLEANUP_CFG , "cfg cleanup")
DEFTIMEVAR (TV_DELETE_TRIVIALLY_DEAD , "trivially dead code")
/* Time spent by life analysis. */
DEFTIMEVAR (TV_LIFE , "life analysis")
DEFTIMEVAR (TV_LIFE_UPDATE , "life info update")
/* Timing in various stages of the compiler. */
DEFTIMEVAR (TV_CPP , "preprocessing")
DEFTIMEVAR (TV_LEX , "lexical analysis")
DEFTIMEVAR (TV_PARSE , "parser")
DEFTIMEVAR (TV_EXPAND , "expand")
DEFTIMEVAR (TV_VARCONST , "varconst")
DEFTIMEVAR (TV_INTEGRATION , "integration")
DEFTIMEVAR (TV_JUMP , "jump")
DEFTIMEVAR (TV_CSE , "CSE")
DEFTIMEVAR (TV_GCSE , "global CSE")
DEFTIMEVAR (TV_LOOP , "loop analysis")
DEFTIMEVAR (TV_TRACER , "tracer")
DEFTIMEVAR (TV_CSE2 , "CSE 2")
DEFTIMEVAR (TV_BRANCH_PROB , "branch prediction")
DEFTIMEVAR (TV_FLOW , "flow analysis")
DEFTIMEVAR (TV_COMBINE , "combiner")
DEFTIMEVAR (TV_IFCVT , "if-conversion")
DEFTIMEVAR (TV_REGMOVE , "regmove")
DEFTIMEVAR (TV_MODE_SWITCH , "mode switching")
DEFTIMEVAR (TV_SCHED , "scheduling")
DEFTIMEVAR (TV_LOCAL_ALLOC , "local alloc")
DEFTIMEVAR (TV_GLOBAL_ALLOC , "global alloc")
DEFTIMEVAR (TV_RELOAD_CSE_REGS , "reload CSE regs")
DEFTIMEVAR (TV_FLOW2 , "flow 2")
DEFTIMEVAR (TV_IFCVT2 , "if-conversion 2")
DEFTIMEVAR (TV_PEEPHOLE2 , "peephole 2")
DEFTIMEVAR (TV_RENAME_REGISTERS , "rename registers")
DEFTIMEVAR (TV_SCHED2 , "scheduling 2")
DEFTIMEVAR (TV_MACH_DEP , "machine dep reorg")
DEFTIMEVAR (TV_DBR_SCHED , "delay branch sched")
DEFTIMEVAR (TV_REORDER_BLOCKS , "reorder blocks")
DEFTIMEVAR (TV_SHORTEN_BRANCH , "shorten branches")
DEFTIMEVAR (TV_REG_STACK , "reg stack")
DEFTIMEVAR (TV_TO_SSA , "convert to SSA")
DEFTIMEVAR (TV_SSA_CCP , "SSA CCP")
DEFTIMEVAR (TV_SSA_DCE , "SSA aggressive DCE")
DEFTIMEVAR (TV_FROM_SSA , "convert from SSA")
DEFTIMEVAR (TV_FINAL , "final")
DEFTIMEVAR (TV_SYMOUT , "symout")
/* Time spent by freeing the memory :). */
DEFTIMEVAR (TV_FREE , "freeing")
/* Everything else in rest_of_compilation not included above. */
DEFTIMEVAR (TV_REST_OF_COMPILATION , "rest of compilation")
+23 -21
View File
@@ -1,19 +1,23 @@
/* Timing variables for measuring compiler performance.
Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
Copyright (C) 2000 Free Software Foundation, Inc.
Contributed by Alex Samuel <samuel@codesourcery.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This file is part of GCC.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#ifndef GCC_TIMEVAR_H
#define GCC_TIMEVAR_H
@@ -72,18 +76,16 @@ typedef enum
timevar_id_t;
#undef DEFTIMEVAR
extern void init_timevar (void);
extern void timevar_push (timevar_id_t);
extern void timevar_pop (timevar_id_t);
extern void timevar_start (timevar_id_t);
extern void timevar_stop (timevar_id_t);
extern void timevar_get (timevar_id_t, struct timevar_time_def *);
extern void timevar_print (FILE *);
extern void init_timevar PARAMS ((void));
extern void timevar_push PARAMS ((timevar_id_t));
extern void timevar_pop PARAMS ((timevar_id_t));
extern void timevar_start PARAMS ((timevar_id_t));
extern void timevar_stop PARAMS ((timevar_id_t));
extern void timevar_get PARAMS ((timevar_id_t, struct timevar_time_def *));
extern void timevar_print PARAMS ((FILE *));
/* Provided for backward compatibility. */
extern long get_run_time (void);
extern void print_time (const char *, long);
extern int timevar_report;
extern long get_run_time PARAMS ((void));
extern void print_time PARAMS ((const char *, long));
#endif /* ! GCC_TIMEVAR_H */
+75 -144
View File
@@ -1,10 +1,10 @@
/* Variable array bitsets.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -13,51 +13,45 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <config.h>
#include "vbitset.h"
#include <stdlib.h>
#include <string.h>
/* This file implements variable size bitsets stored as a variable
length array of words. Any unused bits in the last word must be
zero.
zero.
Note that binary or ternary operations assume that each bitset operand
has the same size.
*/
static void vbitset_unused_clear PARAMS ((bitset));
static void vbitset_unused_clear (bitset);
static void vbitset_set PARAMS ((bitset, bitset_bindex));
static void vbitset_reset PARAMS ((bitset, bitset_bindex));
static bool vbitset_test PARAMS ((bitset, bitset_bindex));
static bitset_bindex vbitset_list PARAMS ((bitset, bitset_bindex *,
bitset_bindex,
bitset_bindex *));
static bitset_bindex vbitset_list_reverse PARAMS ((bitset, bitset_bindex *,
bitset_bindex,
bitset_bindex *));
static void vbitset_set (bitset, bitset_bindex);
static void vbitset_reset (bitset, bitset_bindex);
static bool vbitset_test (bitset, bitset_bindex);
static bitset_bindex vbitset_list (bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *);
static bitset_bindex vbitset_list_reverse (bitset, bitset_bindex *,
bitset_bindex, bitset_bindex *);
#define VBITSET_N_WORDS(N) (((N) + BITSET_WORD_BITS - 1) / BITSET_WORD_BITS)
#define VBITSET_WORDS(X) ((X)->b.cdata)
#define VBITSET_SIZE(X) ((X)->b.csize)
#define VBITSET_ASIZE(X) ((X)->v.size)
#undef min
#undef max
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
static bitset_bindex
vbitset_resize (src, n_bits)
bitset src;
bitset_bindex n_bits;
vbitset_resize (bitset src, bitset_bindex n_bits)
{
bitset_windex oldsize;
bitset_windex newsize;
@@ -72,7 +66,7 @@ vbitset_resize (src, n_bits)
{
bitset_windex size;
/* The bitset needs to grow. If we already have enough memory
/* The bitset needs to grow. If we already have enough memory
allocated, then just zero what we need. */
if (newsize > VBITSET_ASIZE (src))
{
@@ -85,13 +79,13 @@ vbitset_resize (src, n_bits)
size = newsize;
else
size = newsize + newsize / 4;
VBITSET_WORDS (src)
= realloc (VBITSET_WORDS (src), size * sizeof (bitset_word));
VBITSET_ASIZE (src) = size;
}
memset (VBITSET_WORDS (src) + oldsize, 0,
memset (VBITSET_WORDS (src) + oldsize, 0,
(newsize - oldsize) * sizeof (bitset_word));
VBITSET_SIZE (src) = newsize;
}
@@ -343,8 +337,7 @@ vbitset_unused_clear (dst)
static void
vbitset_ones (dst)
bitset dst;
vbitset_ones (bitset dst)
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned int bytes;
@@ -357,8 +350,7 @@ vbitset_ones (dst)
static void
vbitset_zero (dst)
bitset dst;
vbitset_zero (bitset dst)
{
bitset_word *dstp = VBITSET_WORDS (dst);
unsigned int bytes;
@@ -370,8 +362,7 @@ vbitset_zero (dst)
static bool
vbitset_empty_p (dst)
bitset dst;
vbitset_empty_p (bitset dst)
{
unsigned int i;
bitset_word *dstp = VBITSET_WORDS (dst);
@@ -385,9 +376,7 @@ vbitset_empty_p (dst)
static void
vbitset_copy1 (dst, src)
bitset dst;
bitset src;
vbitset_copy1 (bitset dst, bitset src)
{
bitset_word *srcp;
bitset_word *dstp;
@@ -412,9 +401,7 @@ vbitset_copy1 (dst, src)
static void
vbitset_not (dst, src)
bitset dst;
bitset src;
vbitset_not (bitset dst, bitset src)
{
unsigned int i;
bitset_word *srcp;
@@ -437,11 +424,9 @@ vbitset_not (dst, src)
sizeof (bitset_word) * (dsize - ssize));
}
static bool
vbitset_equal_p (dst, src)
bitset dst;
bitset src;
vbitset_equal_p (bitset dst, bitset src)
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -471,16 +456,14 @@ vbitset_equal_p (dst, src)
static bool
vbitset_subset_p (dst, src)
bitset dst;
bitset src;
vbitset_subset_p (bitset dst, bitset src)
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
bitset_word *dstp = VBITSET_WORDS (dst);
bitset_windex ssize = VBITSET_SIZE (src);
bitset_windex dsize = VBITSET_SIZE (dst);
for (i = 0; i < min (ssize, dsize); i++, dstp++, srcp++)
if (*dstp != (*srcp | *dstp))
return 0;
@@ -497,9 +480,7 @@ vbitset_subset_p (dst, src)
static bool
vbitset_disjoint_p (dst, src)
bitset dst;
bitset src;
vbitset_disjoint_p (bitset dst, bitset src)
{
unsigned int i;
bitset_word *srcp = VBITSET_WORDS (src);
@@ -516,10 +497,7 @@ vbitset_disjoint_p (dst, src)
static void
vbitset_and (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
vbitset_and (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
bitset_word *src1p;
@@ -540,16 +518,13 @@ vbitset_and (dst, src1, src2)
for (i = 0; i < min (ssize1, ssize2); i++)
*dstp++ = *src1p++ & *src2p++;
memset (dstp, 0, sizeof (bitset_word) * (dsize - min (ssize1, ssize2)));
}
static bool
vbitset_and_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
vbitset_and_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
int changed = 0;
@@ -572,14 +547,14 @@ vbitset_and_cmp (dst, src1, src2)
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
{
bitset_word tmp = *src1p++ & *src2p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
}
if (ssize2 > ssize1)
{
src1p = src2p;
@@ -602,10 +577,7 @@ vbitset_and_cmp (dst, src1, src2)
static void
vbitset_andn (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
vbitset_andn (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
bitset_word *src1p;
@@ -626,7 +598,7 @@ vbitset_andn (dst, src1, src2)
for (i = 0; i < min (ssize1, ssize2); i++)
*dstp++ = *src1p++ & ~(*src2p++);
if (ssize2 > ssize1)
{
for (; i < ssize2; i++)
@@ -645,10 +617,7 @@ vbitset_andn (dst, src1, src2)
static bool
vbitset_andn_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
vbitset_andn_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
int changed = 0;
@@ -671,14 +640,14 @@ vbitset_andn_cmp (dst, src1, src2)
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
{
bitset_word tmp = *src1p++ & ~(*src2p++);
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
}
if (ssize2 > ssize1)
{
for (; i < ssize2; i++, dstp++)
@@ -697,7 +666,7 @@ vbitset_andn_cmp (dst, src1, src2)
for (; i < ssize1; i++, dstp++)
{
bitset_word tmp = *src1p++;
if (*dstp != tmp)
{
changed = 1;
@@ -713,10 +682,7 @@ vbitset_andn_cmp (dst, src1, src2)
static void
vbitset_or (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
vbitset_or (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
bitset_word *src1p;
@@ -737,7 +703,7 @@ vbitset_or (dst, src1, src2)
for (i = 0; i < min (ssize1, ssize2); i++)
*dstp++ = *src1p++ | *src2p++;
if (ssize2 > ssize1)
{
src1p = src2p;
@@ -752,10 +718,7 @@ vbitset_or (dst, src1, src2)
static bool
vbitset_or_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
vbitset_or_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
int changed = 0;
@@ -778,14 +741,14 @@ vbitset_or_cmp (dst, src1, src2)
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
{
bitset_word tmp = *src1p++ | *src2p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
}
if (ssize2 > ssize1)
{
src1p = src2p;
@@ -795,7 +758,7 @@ vbitset_or_cmp (dst, src1, src2)
for (; i < ssize1; i++, dstp++)
{
bitset_word tmp = *src1p++;
if (*dstp != tmp)
{
changed = 1;
@@ -810,10 +773,7 @@ vbitset_or_cmp (dst, src1, src2)
static void
vbitset_xor (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
vbitset_xor (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
bitset_word *src1p;
@@ -834,7 +794,7 @@ vbitset_xor (dst, src1, src2)
for (i = 0; i < min (ssize1, ssize2); i++)
*dstp++ = *src1p++ ^ *src2p++;
if (ssize2 > ssize1)
{
src1p = src2p;
@@ -849,10 +809,7 @@ vbitset_xor (dst, src1, src2)
static bool
vbitset_xor_cmp (dst, src1, src2)
bitset dst;
bitset src1;
bitset src2;
vbitset_xor_cmp (bitset dst, bitset src1, bitset src2)
{
unsigned int i;
int changed = 0;
@@ -875,14 +832,14 @@ vbitset_xor_cmp (dst, src1, src2)
for (i = 0; i < min (ssize1, ssize2); i++, dstp++)
{
bitset_word tmp = *src1p++ ^ *src2p++;
if (*dstp != tmp)
{
changed = 1;
*dstp = tmp;
}
}
if (ssize2 > ssize1)
{
src1p = src2p;
@@ -892,7 +849,7 @@ vbitset_xor_cmp (dst, src1, src2)
for (; i < ssize1; i++, dstp++)
{
bitset_word tmp = *src1p++;
if (*dstp != tmp)
{
changed = 1;
@@ -910,11 +867,7 @@ vbitset_xor_cmp (dst, src1, src2)
bitsets. */
static void
vbitset_and_or (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
vbitset_and_or (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
bitset_word *src1p;
@@ -922,7 +875,7 @@ vbitset_and_or (dst, src1, src2, src3)
bitset_word *src3p;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
{
@@ -944,11 +897,7 @@ vbitset_and_or (dst, src1, src2, src3)
static bool
vbitset_and_or_cmp (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
vbitset_and_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
int changed = 0;
@@ -957,7 +906,7 @@ vbitset_and_or_cmp (dst, src1, src2, src3)
bitset_word *src3p;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
return bitset_and_or_cmp_ (dst, src1, src2, src3);
@@ -969,11 +918,11 @@ vbitset_and_or_cmp (dst, src1, src2, src3)
src3p = VBITSET_WORDS (src3);
dstp = VBITSET_WORDS (dst);
size = VBITSET_SIZE (dst);
for (i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ & *src2p++) | *src3p++;
if (*dstp != tmp)
{
changed = 1;
@@ -985,11 +934,7 @@ vbitset_and_or_cmp (dst, src1, src2, src3)
static void
vbitset_andn_or (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
vbitset_andn_or (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
bitset_word *src1p;
@@ -997,7 +942,7 @@ vbitset_andn_or (dst, src1, src2, src3)
bitset_word *src3p;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
{
@@ -1019,11 +964,7 @@ vbitset_andn_or (dst, src1, src2, src3)
static bool
vbitset_andn_or_cmp (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
vbitset_andn_or_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
int changed = 0;
@@ -1032,7 +973,7 @@ vbitset_andn_or_cmp (dst, src1, src2, src3)
bitset_word *src3p;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
return bitset_andn_or_cmp_ (dst, src1, src2, src3);
@@ -1044,11 +985,11 @@ vbitset_andn_or_cmp (dst, src1, src2, src3)
src3p = VBITSET_WORDS (src3);
dstp = VBITSET_WORDS (dst);
size = VBITSET_SIZE (dst);
for (i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ & ~(*src2p++)) | *src3p++;
if (*dstp != tmp)
{
changed = 1;
@@ -1060,11 +1001,7 @@ vbitset_andn_or_cmp (dst, src1, src2, src3)
static void
vbitset_or_and (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
vbitset_or_and (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
bitset_word *src1p;
@@ -1072,7 +1009,7 @@ vbitset_or_and (dst, src1, src2, src3)
bitset_word *src3p;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
{
@@ -1087,18 +1024,14 @@ vbitset_or_and (dst, src1, src2, src3)
src3p = VBITSET_WORDS (src3);
dstp = VBITSET_WORDS (dst);
size = VBITSET_SIZE (dst);
for (i = 0; i < size; i++)
*dstp++ = (*src1p++ | *src2p++) & *src3p++;
}
static bool
vbitset_or_and_cmp (dst, src1, src2, src3)
bitset dst;
bitset src1;
bitset src2;
bitset src3;
vbitset_or_and_cmp (bitset dst, bitset src1, bitset src2, bitset src3)
{
unsigned int i;
int changed = 0;
@@ -1107,7 +1040,7 @@ vbitset_or_and_cmp (dst, src1, src2, src3)
bitset_word *src3p;
bitset_word *dstp;
bitset_windex size;
if (BITSET_NBITS_ (src1) != BITSET_NBITS_ (src2)
|| BITSET_NBITS_ (src1) != BITSET_NBITS_ (src3))
return bitset_or_and_cmp_ (dst, src1, src2, src3);
@@ -1119,11 +1052,11 @@ vbitset_or_and_cmp (dst, src1, src2, src3)
src3p = VBITSET_WORDS (src3);
dstp = VBITSET_WORDS (dst);
size = VBITSET_SIZE (dst);
for (i = 0; i < size; i++, dstp++)
{
bitset_word tmp = (*src1p++ | *src2p++) & *src3p++;
if (*dstp != tmp)
{
changed = 1;
@@ -1134,10 +1067,8 @@ vbitset_or_and_cmp (dst, src1, src2, src3)
}
void
vbitset_copy (dst, src)
bitset dst;
bitset src;
static void
vbitset_copy (bitset dst, bitset src)
{
if (BITSET_COMPATIBLE_ (dst, src))
vbitset_copy1 (dst, src);
+14 -15
View File
@@ -1,28 +1,27 @@
/* Functions to support vbitsets.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _VBITSET_H
#define _VBITSET_H
#define _VBITSET_H
#include "bitset.h"
extern size_t vbitset_bytes PARAMS ((bitset_bindex));
extern size_t vbitset_bytes (bitset_bindex);
extern bitset vbitset_init PARAMS ((bitset, bitset_bindex));
extern bitset vbitset_init (bitset, bitset_bindex);
#endif