diff options
author | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-12-05 00:20:43 +0000 |
---|---|---|
committer | mmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4> | 1999-12-05 00:20:43 +0000 |
commit | 395adca102ab69984f3d2924bac27bc71893a8d9 (patch) | |
tree | 140a755d82250e682ae8859b95daa46daee2869d /gcc | |
parent | 6a9ea91e90b1bd20de578745635380d15ab4ddd7 (diff) | |
download | gcc-395adca102ab69984f3d2924bac27bc71893a8d9.tar.gz |
* varray.h (varray_head_tag): Add elements_used.
(VARRAY_PUSH): New macro.
(VARRAY_POP): Likewise.
(VARRAY_TOP): Likewise.
Add variants of VARRAY_PUSH and VARRAY_POP for all varray element
types.
* varray.c (varray_init): Initialize elements_used.
* Makefile.in (BASIC_BLOCK_H): Add varray.h.
(INTEGRATE_H): New variable.
(integrate.o): Depend on INTEGRATE_H.
(unroll.o): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30777 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/Makefile.in | 8 | ||||
-rw-r--r-- | gcc/varray.c | 3 | ||||
-rw-r--r-- | gcc/varray.h | 65 |
3 files changed, 72 insertions, 4 deletions
diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 61144c4f14c..9ac6d32a99d 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -743,11 +743,12 @@ MACHMODE_H = machmode.h machmode.def RTL_BASE_H = rtl.h rtl.def $(MACHMODE_H) RTL_H = $(RTL_BASE_H) genrtl.h TREE_H = tree.h real.h tree.def $(MACHMODE_H) tree-check.h -BASIC_BLOCK_H = basic-block.h bitmap.h sbitmap.h +BASIC_BLOCK_H = basic-block.h bitmap.h sbitmap.h varray.h DEMANGLE_H = $(srcdir)/../include/demangle.h RECOG_H = recog.h EXPR_H = expr.h insn-codes.h REGS_H = regs.h varray.h $(MACHMODE_H) +INTREGRATE_H = integrate.h varray.h LOOP_H = loop.h varray.h # # Language makefile fragments. @@ -1527,7 +1528,7 @@ emit-rtl.o : emit-rtl.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h \ $(EXPR_H) $(srcdir)/../include/obstack.h hard-reg-set.h bitmap.h toplev.h real.o : real.c $(CONFIG_H) system.h $(TREE_H) toplev.h integrate.o : integrate.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h \ - integrate.h insn-flags.h insn-config.h $(EXPR_H) real.h $(REGS_H) \ + $(INTEGRATE_H) insn-flags.h insn-config.h $(EXPR_H) real.h $(REGS_H) \ intl.h function.h output.h $(RECOG_H) except.h toplev.h $(LOOP_H) jump.o : jump.c $(CONFIG_H) system.h $(RTL_H) flags.h hard-reg-set.h $(REGS_H) \ insn-config.h insn-flags.h $(RECOG_H) $(EXPR_H) real.h except.h function.h \ @@ -1555,7 +1556,8 @@ loop.o : loop.c $(CONFIG_H) system.h $(RTL_H) flags.h $(LOOP_H) insn-config.h \ insn-flags.h $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) real.h \ $(BASIC_BLOCK_H) function.h toplev.h varray.h except.h unroll.o : unroll.c $(CONFIG_H) system.h $(RTL_H) insn-config.h function.h \ - integrate.h $(REGS_H) $(RECOG_H) flags.h $(EXPR_H) $(LOOP_H) toplev.h varray.h + $(INTEGRATE_H) $(REGS_H) $(RECOG_H) flags.h $(EXPR_H) $(LOOP_H) toplev.h \ + varray.h flow.o : flow.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h insn-config.h \ $(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \ insn-flags.h function.h except.h diff --git a/gcc/varray.c b/gcc/varray.c index 34ce80b284b..516913617af 100644 --- a/gcc/varray.c +++ b/gcc/varray.c @@ -40,8 +40,9 @@ varray_init (num_elements, element_size, name) varray_type ptr = (varray_type) xcalloc (VARRAY_HDR_SIZE + data_size, 1); ptr->num_elements = num_elements; + ptr->elements_used = 0; ptr->element_size = element_size; - ptr->name = name; + ptr->name = name; return ptr; } diff --git a/gcc/varray.h b/gcc/varray.h index 51be0146bce..0d1843bef0d 100644 --- a/gcc/varray.h +++ b/gcc/varray.h @@ -81,6 +81,8 @@ typedef union varray_data_tag { /* Virtual array of pointers header. */ typedef struct varray_head_tag { size_t num_elements; /* maximum element number allocated */ + size_t elements_used; /* the number of elements used, if + using VARRAY_PUSH/VARRAY_POP. */ size_t element_size; /* size of each data element */ const char *name; /* name of the varray for reporting errors */ varray_data data; /* data elements follow, must be last */ @@ -178,6 +180,25 @@ extern void varray_check_failed PROTO ((varray_type, size_t, #define VARRAY_CHECK(VA, N, T) ((VA)->data.T[N]) #endif +/* Push X onto VA. T is the name of the field in varray_data + corresponding to the type of X. */ +#define VARRAY_PUSH(VA, T, X) \ + do \ + { \ + if ((VA)->elements_used >= (VA)->num_elements) \ + VARRAY_GROW ((VA), 2 * (VA)->num_elements); \ + (VA)->data.T[(VA)->elements_used++] = (X); \ + } \ + while (0) + +/* Pop the top element of VA. */ +#define VARRAY_POP(VA) \ + ((VA)->elements_used--) + +/* Return the top element of VA. */ +#define VARRAY_TOP(VA, T) \ + ((VA)->data.T[(VA)->elements_used - 1]) + #define VARRAY_CHAR(VA, N) VARRAY_CHECK (VA, N, c) #define VARRAY_UCHAR(VA, N) VARRAY_CHECK (VA, N, uc) #define VARRAY_SHORT(VA, N) VARRAY_CHECK (VA, N, s) @@ -199,4 +220,48 @@ extern void varray_check_failed PROTO ((varray_type, size_t, #define VARRAY_CONST_EQUIV(VA, N) VARRAY_CHECK (VA, N, const_equiv) #define VARRAY_BB(VA, N) VARRAY_CHECK (VA, N, bb) +/* Push a new element on the end of VA, extending it if necessary. */ +#define VARRAY_PUSH_CHAR(VA, X) VARRAY_PUSH (VA, c, X) +#define VARRAY_PUSH_UCHAR(VA, X) VARRAY_PUSH (VA, uc, X) +#define VARRAY_PUSH_SHORT(VA, X) VARRAY_PUSH (VA, s, X) +#define VARRAY_PUSH_USHORT(VA, X) VARRAY_PUSH (VA, us, X) +#define VARRAY_PUSH_INT(VA, X) VARRAY_PUSH (VA, i, X) +#define VARRAY_PUSH_UINT(VA, X) VARRAY_PUSH (VA, u, X) +#define VARRAY_PUSH_LONG(VA, X) VARRAY_PUSH (VA, l, X) +#define VARRAY_PUSH_ULONG(VA, X) VARRAY_PUSH (VA, ul, X) +#define VARRAY_PUSH_WIDE_INT(VA, X) VARRAY_PUSH (VA, hint, X) +#define VARRAY_PUSH_UWIDE_INT(VA, X) VARRAY_PUSH (VA, uhint, X) +#define VARRAY_PUSH_GENERIC_PTR(VA,N) VARRAY_PUSH (VA, generic, X) +#define VARRAY_PUSH_CHAR_PTR(VA,N) VARRAY_PUSH (VA, cptr, X) +#define VARRAY_PUSH_RTX(VA, X) VARRAY_PUSH (VA, rtx, X) +#define VARRAY_PUSH_RTVEC(VA, X) VARRAY_PUSH (VA, rtvec, X) +#define VARRAY_PUSH_TREE(VA, X) VARRAY_PUSH (VA, tree, X) +#define VARRAY_PUSH_BITMAP(VA, X) VARRAY_PUSH (VA, bitmap, X) +#define VARRAY_PUSH_SCHED(VA, X) VARRAY_PUSH (VA, sched, X) +#define VARRAY_PUSH_REG(VA, X) VARRAY_PUSH (VA, reg, X) +#define VARRAY_PUSH_CONST_EQUIV(VA, X) VARRAY_PUSH (VA, const_equiv, X) +#define VARRAY_PUSH_BB(VA, X) VARRAY_PUSH (VA, bb, X) + +/* Return the last element of VA. */ +#define VARRAY_TOP_CHAR(VA) VARRAY_TOP (VA, c) +#define VARRAY_TOP_UCHAR(VA) VARRAY_TOP (VA, uc) +#define VARRAY_TOP_SHORT(VA) VARRAY_TOP (VA, s) +#define VARRAY_TOP_USHORT(VA) VARRAY_TOP (VA, us) +#define VARRAY_TOP_INT(VA) VARRAY_TOP (VA, i) +#define VARRAY_TOP_UINT(VA) VARRAY_TOP (VA, u) +#define VARRAY_TOP_LONG(VA) VARRAY_TOP (VA, l) +#define VARRAY_TOP_ULONG(VA) VARRAY_TOP (VA, ul) +#define VARRAY_TOP_WIDE_INT(VA) VARRAY_TOP (VA, hint) +#define VARRAY_TOP_UWIDE_INT(VA) VARRAY_TOP (VA, uhint) +#define VARRAY_TOP_GENERIC_PTR(VA,N) VARRAY_TOP (VA, generic) +#define VARRAY_TOP_CHAR_PTR(VA,N) VARRAY_TOP (VA, cptr) +#define VARRAY_TOP_RTX(VA) VARRAY_TOP (VA, rtx) +#define VARRAY_TOP_RTVEC(VA) VARRAY_TOP (VA, rtvec) +#define VARRAY_TOP_TREE(VA) VARRAY_TOP (VA, tree) +#define VARRAY_TOP_BITMAP(VA) VARRAY_TOP (VA, bitmap) +#define VARRAY_TOP_SCHED(VA) VARRAY_TOP (VA, sched) +#define VARRAY_TOP_REG(VA) VARRAY_TOP (VA, reg) +#define VARRAY_TOP_CONST_EQUIV(VA) VARRAY_TOP (VA, const_equiv) +#define VARRAY_TOP_BB(VA) VARRAY_TOP (VA, bb) + #endif /* _VARRAY_H_ */ |