diff options
Diffstat (limited to 'gcc/rtl.c')
-rw-r--r-- | gcc/rtl.c | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/gcc/rtl.c b/gcc/rtl.c index 4b14dabf5cc..db28096ac65 100644 --- a/gcc/rtl.c +++ b/gcc/rtl.c @@ -24,7 +24,7 @@ Boston, MA 02111-1307, USA. */ #include "rtl.h" #include "real.h" #include "bitmap.h" - +#include "ggc.h" #include "obstack.h" #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free @@ -244,18 +244,23 @@ rtvec_alloc (n) int n; { rtvec rt; - int i; - - rt = (rtvec) obstack_alloc (rtl_obstack, - sizeof (struct rtvec_def) - + (( n - 1) * sizeof (rtx))); + + if (ggc_p) + rt = ggc_alloc_rtvec (n); + else + { + int i; - /* clear out the vector */ - PUT_NUM_ELEM (rt, n); + rt = (rtvec) obstack_alloc (rtl_obstack, + sizeof (struct rtvec_def) + + (( n - 1) * sizeof (rtx))); - for (i = 0; i < n; i++) - rt->elem[i] = 0; + /* clear out the vector */ + for (i = 0; i < n; i++) + rt->elem[i] = 0; + } + PUT_NUM_ELEM (rt, n); return rt; } @@ -267,34 +272,40 @@ rtx_alloc (code) RTX_CODE code; { rtx rt; - register struct obstack *ob = rtl_obstack; - register int nelts = GET_RTX_LENGTH (code); - register int length = sizeof (struct rtx_def) - + (nelts - 1) * sizeof (rtunion); - - /* This function is called more than any other in GCC, - so we manipulate the obstack directly. - Even though rtx objects are word aligned, we may be sharing an obstack - with tree nodes, which may have to be double-word aligned. So align - our length to the alignment mask in the obstack. */ - - length = (length + ob->alignment_mask) & ~ ob->alignment_mask; - - if (ob->chunk_limit - ob->next_free < length) - _obstack_newchunk (ob, length); - rt = (rtx)ob->object_base; - ob->next_free += length; - ob->object_base = ob->next_free; - - /* We want to clear everything up to the FLD array. Normally, this is - one int, but we don't want to assume that and it isn't very portable - anyway; this is. */ - - memset (rt, 0, sizeof (struct rtx_def) - sizeof (rtunion)); + if (ggc_p) + rt = ggc_alloc_rtx (GET_RTX_LENGTH (code)); + else + { + register struct obstack *ob = rtl_obstack; + register int nelts = GET_RTX_LENGTH (code); + register int length = sizeof (struct rtx_def) + + (nelts - 1) * sizeof (rtunion); + + /* This function is called more than any other in GCC, so we + manipulate the obstack directly. + + Even though rtx objects are word aligned, we may be sharing + an obstack with tree nodes, which may have to be double-word + aligned. So align our length to the alignment mask in the + obstack. */ + + length = (length + ob->alignment_mask) & ~ ob->alignment_mask; + + if (ob->chunk_limit - ob->next_free < length) + _obstack_newchunk (ob, length); + rt = (rtx)ob->object_base; + ob->next_free += length; + ob->object_base = ob->next_free; + + /* We want to clear everything up to the FLD array. Normally, + this is one int, but we don't want to assume that and it + isn't very portable anyway; this is. */ + + memset (rt, 0, sizeof (struct rtx_def) - sizeof (rtunion)); + } PUT_CODE (rt, code); - return rt; } @@ -304,7 +315,8 @@ void rtx_free (x) rtx x; { - obstack_free (rtl_obstack, x); + if (!ggc_p) + obstack_free (rtl_obstack, x); } /* Create a new copy of an rtx. |