From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129324 invoked by alias); 5 Oct 2016 15:44:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 129075 invoked by uid 89); 5 Oct 2016 15:44:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 spammy= X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Oct 2016 15:44:45 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1broN6-0000L9-0V for gcc-patches@gcc.gnu.org; Wed, 05 Oct 2016 11:44:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1broN5-0000Kg-NI for gcc-patches@gcc.gnu.org; Wed, 05 Oct 2016 11:44:39 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A95757CDF0 for ; Wed, 5 Oct 2016 15:44:37 +0000 (UTC) Received: from c64.redhat.com (vpn-236-9.phx2.redhat.com [10.3.236.9]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u95FiV5O027350; Wed, 5 Oct 2016 11:44:37 -0400 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [PATCH 06/16] Introduce emit_status::ensure_regno_capacity Date: Wed, 05 Oct 2016 15:45:00 -0000 Message-Id: <1475684110-2521-7-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1475684110-2521-1-git-send-email-dmalcolm@redhat.com> References: <1475684110-2521-1-git-send-email-dmalcolm@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00264.txt.bz2 gcc/ChangeLog: * emit-rtl.c (gen_reg_rtx): Move regno_pointer_align and regno_reg_rtx resizing logic to... (emit_status::ensure_regno_capacity): ...this new method. (init_emit): Allocate regno_reg_rtx using ggc_cleared_vec_alloc rather than ggc_vec_alloc. * function.h (emit_status::ensure_regno_capacity): New method. --- gcc/emit-rtl.c | 45 ++++++++++++++++++++++++++------------------- gcc/function.h | 2 ++ 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index fdfc790..12bdbb0 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1056,29 +1056,35 @@ gen_reg_rtx (machine_mode mode) /* Do not call gen_reg_rtx with uninitialized crtl. */ gcc_assert (crtl->emit.regno_pointer_align_length); - /* Make sure regno_pointer_align, and regno_reg_rtx are large - enough to have an element for this pseudo reg number. */ + int cur_size = crtl->emit.regno_pointer_align_length; + if (reg_rtx_no == cur_size) + crtl->emit.ensure_regno_capacity (cur_size * 2); - if (reg_rtx_no == crtl->emit.regno_pointer_align_length) - { - int old_size = crtl->emit.regno_pointer_align_length; - char *tmp; - rtx *new1; + val = gen_raw_REG (mode, reg_rtx_no); + regno_reg_rtx[reg_rtx_no++] = val; + return val; +} + +/* Make sure m_regno_pointer_align, and regno_reg_rtx are large + enough to have elements in the range 0 <= idx < NEW_SIZE. */ + +void +emit_status::ensure_regno_capacity (int new_size) +{ + if (new_size < regno_pointer_align_length) + return; - tmp = XRESIZEVEC (char, crtl->emit.regno_pointer_align, old_size * 2); - memset (tmp + old_size, 0, old_size); - crtl->emit.regno_pointer_align = (unsigned char *) tmp; + int old_size = regno_pointer_align_length; - new1 = GGC_RESIZEVEC (rtx, regno_reg_rtx, old_size * 2); - memset (new1 + old_size, 0, old_size * sizeof (rtx)); - regno_reg_rtx = new1; + char *tmp = XRESIZEVEC (char, regno_pointer_align, new_size); + memset (tmp + old_size, 0, new_size - old_size); + regno_pointer_align = (unsigned char *) tmp; - crtl->emit.regno_pointer_align_length = old_size * 2; - } + rtx *new1 = GGC_RESIZEVEC (rtx, regno_reg_rtx, new_size); + memset (new1 + old_size, 0, (new_size - old_size) * sizeof (rtx)); + regno_reg_rtx = new1; - val = gen_raw_REG (mode, reg_rtx_no); - regno_reg_rtx[reg_rtx_no++] = val; - return val; + crtl->emit.regno_pointer_align_length = new_size; } /* Return TRUE if REG is a PARM_DECL, FALSE otherwise. */ @@ -5667,7 +5673,8 @@ init_emit (void) crtl->emit.regno_pointer_align = XCNEWVEC (unsigned char, crtl->emit.regno_pointer_align_length); - regno_reg_rtx = ggc_vec_alloc (crtl->emit.regno_pointer_align_length); + regno_reg_rtx = + ggc_cleared_vec_alloc (crtl->emit.regno_pointer_align_length); /* Put copies of all the hard registers into regno_reg_rtx. */ memcpy (regno_reg_rtx, diff --git a/gcc/function.h b/gcc/function.h index 590a490..db9f4ea 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -34,6 +34,8 @@ struct GTY(()) sequence_stack { }; struct GTY(()) emit_status { + void ensure_regno_capacity (int new_size); + /* This is reset to LAST_VIRTUAL_REGISTER + 1 at the start of each function. After rtl generation, it is 1 plus the largest register number used. */ int x_reg_rtx_no; -- 1.8.5.3