Commit 19a7414e by Mike Stump Committed by Mike Stump

varray.c (element_size): Remove.

	* varray.c (element_size): Remove.
	(uses_ggc): Remove.
	(element): Add.
	(varray_init): Use new interface.
	(varray_grow): Use new interface.
	(varray_clear): Use new interface.

From-SVN: r62810
parent e3c33425
2003-02-12 Mike Stump <mrs@apple.com>
* varray.c (element_size): Remove.
(uses_ggc): Remove.
(element): Add.
(varray_init): Use new interface.
(varray_grow): Use new interface.
(varray_clear): Use new interface.
2003-02-12 Aldy Hernandez <aldyh@redhat.com> 2003-02-12 Aldy Hernandez <aldyh@redhat.com>
* config/rs6000/spe.h: Add casts to the arguments of the following * config/rs6000/spe.h: Add casts to the arguments of the following
......
...@@ -29,34 +29,33 @@ ...@@ -29,34 +29,33 @@
#define VARRAY_HDR_SIZE (sizeof (struct varray_head_tag) - sizeof (varray_data)) #define VARRAY_HDR_SIZE (sizeof (struct varray_head_tag) - sizeof (varray_data))
static const size_t element_size[NUM_VARRAY_DATA] = { /* Do not add any more non-GC items here. Please either remove or GC those items that
sizeof (char), are not GCed. */
sizeof (unsigned char),
sizeof (short), static const struct {
sizeof (unsigned short), unsigned char size;
sizeof (int), bool uses_ggc;
sizeof (unsigned int), } element[NUM_VARRAY_DATA] = {
sizeof (long), { sizeof (char), 1 },
sizeof (unsigned long), { sizeof (unsigned char), 1 },
sizeof (HOST_WIDE_INT), { sizeof (short), 1 },
sizeof (unsigned HOST_WIDE_INT), { sizeof (unsigned short), 1 },
sizeof (PTR), { sizeof (int), 1 },
sizeof (char *), { sizeof (unsigned int), 1 },
sizeof (struct rtx_def *), { sizeof (long), 1 },
sizeof (struct rtvec_def *), { sizeof (unsigned long), 1 },
sizeof (union tree_node *), { sizeof (HOST_WIDE_INT), 1 },
sizeof (struct bitmap_head_def *), { sizeof (unsigned HOST_WIDE_INT), 1 },
sizeof (struct reg_info_def *), { sizeof (PTR), 1 },
sizeof (struct const_equiv_data), { sizeof (char *), 1 },
sizeof (struct basic_block_def *), { sizeof (struct rtx_def *), 1 },
sizeof (struct elt_list *) { sizeof (struct rtvec_def *), 1 },
}; { sizeof (union tree_node *), 1 },
{ sizeof (struct bitmap_head_def *), 1 },
static const int uses_ggc[NUM_VARRAY_DATA] = { { sizeof (struct reg_info_def *), 0 },
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* unsigned HOST_WIDE_INT */ { sizeof (struct const_equiv_data), 0 },
1, /* PTR */ { sizeof (struct basic_block_def *), 0 },
1, 1, 1, 1, 1, /* bitmap_head_def */ { sizeof (struct elt_list *), 1 },
0, 0, 0, 1
}; };
/* Allocate a virtual array with NUM_ELEMENT elements, each of which is /* Allocate a virtual array with NUM_ELEMENT elements, each of which is
...@@ -67,9 +66,9 @@ varray_init (num_elements, element_kind, name) ...@@ -67,9 +66,9 @@ varray_init (num_elements, element_kind, name)
enum varray_data_enum element_kind; enum varray_data_enum element_kind;
const char *name; const char *name;
{ {
size_t data_size = num_elements * element_size[element_kind]; size_t data_size = num_elements * element[element_kind].size;
varray_type ptr; varray_type ptr;
if (uses_ggc [element_kind]) if (element[element_kind].uses_ggc)
ptr = (varray_type) ggc_alloc_cleared (VARRAY_HDR_SIZE + data_size); ptr = (varray_type) ggc_alloc_cleared (VARRAY_HDR_SIZE + data_size);
else else
ptr = (varray_type) xcalloc (VARRAY_HDR_SIZE + data_size, 1); ptr = (varray_type) xcalloc (VARRAY_HDR_SIZE + data_size, 1);
...@@ -92,11 +91,11 @@ varray_grow (va, n) ...@@ -92,11 +91,11 @@ varray_grow (va, n)
if (n != old_elements) if (n != old_elements)
{ {
size_t elem_size = element_size[va->type]; size_t elem_size = element[va->type].size;
size_t old_data_size = old_elements * elem_size; size_t old_data_size = old_elements * elem_size;
size_t data_size = n * elem_size; size_t data_size = n * elem_size;
if (uses_ggc[va->type]) if (element[va->type].uses_ggc)
va = (varray_type) ggc_realloc (va, VARRAY_HDR_SIZE + data_size); va = (varray_type) ggc_realloc (va, VARRAY_HDR_SIZE + data_size);
else else
va = (varray_type) xrealloc ((char *) va, VARRAY_HDR_SIZE + data_size); va = (varray_type) xrealloc ((char *) va, VARRAY_HDR_SIZE + data_size);
...@@ -113,7 +112,7 @@ void ...@@ -113,7 +112,7 @@ void
varray_clear (va) varray_clear (va)
varray_type va; varray_type va;
{ {
size_t data_size = element_size[va->type] * va->num_elements; size_t data_size = element[va->type].size * va->num_elements;
memset (va->data.c, 0, data_size); memset (va->data.c, 0, data_size);
va->elements_used = 0; va->elements_used = 0;
......
...@@ -57,7 +57,7 @@ struct const_equiv_data GTY(()) { ...@@ -57,7 +57,7 @@ struct const_equiv_data GTY(()) {
}; };
/* Enum indicating what the varray contains. /* Enum indicating what the varray contains.
If this is changed, `element_size' in varray.c needs to be updated. */ If this is changed, `element' in varray.c needs to be updated. */
enum varray_data_enum { enum varray_data_enum {
VARRAY_DATA_C, VARRAY_DATA_C,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment