public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH 3/9] Introduce emit_status::ensure_regno_capacity
Date: Fri, 11 Nov 2016 20:43:00 -0000	[thread overview]
Message-ID: <1478898935-46932-4-git-send-email-dmalcolm@redhat.com> (raw)
In-Reply-To: <1478898935-46932-1-git-send-email-dmalcolm@redhat.com>

Link to earlier version of the patch:
  https://gcc.gnu.org/ml/gcc-patches/2016-10/msg00278.html

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 e995899..50cd388 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -1057,29 +1057,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<rtx> (crtl->emit.regno_pointer_align_length);
+  regno_reg_rtx =
+    ggc_cleared_vec_alloc<rtx> (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 e854c7f..9fe479c 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -34,6 +34,8 @@ struct GTY(()) sequence_stack {
 };
 \f
 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

  reply	other threads:[~2016-11-11 20:43 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-11 20:44 [PATCH 0/9] RTL frontend v4 David Malcolm
2016-11-11 20:43 ` David Malcolm [this message]
2016-11-14 14:17   ` [PATCH 3/9] Introduce emit_status::ensure_regno_capacity Bernd Schmidt
2016-11-14 14:31     ` David Malcolm
2016-11-23 20:12   ` Jeff Law
2016-11-11 20:43 ` [PATCH 2/9] (approved) Introduce rtl_data::init_stack_alignment David Malcolm
2016-11-23 20:09   ` Jeff Law
2016-11-11 20:44 ` [PATCH 1/9] print_rtx: implement support for reuse IDs (v2) David Malcolm
2016-12-01 23:05   ` Jeff Law
2016-12-02  1:37     ` David Malcolm
2016-12-02 15:28       ` Bernd Schmidt
2016-11-11 20:44 ` [PATCH 5/9] Introduce selftest::locate_file (v4) David Malcolm
2016-12-01 13:29   ` Bernd Schmidt
2016-12-02  1:20     ` David Malcolm
2016-12-08 21:47     ` David Malcolm
2016-12-09  1:48       ` Bernd Schmidt
2016-12-09 19:32         ` PR target/78213 revisited (was Re: [PATCH 5/9] Introduce selftest::locate_file (v4)) David Malcolm
2016-12-14 14:04           ` Bernd Schmidt
2016-12-15  2:14             ` [committed] Introduce selftest::locate_file (v5) David Malcolm
2021-08-17  7:00               ` Thomas Schwinge
2021-08-17  9:00                 ` Richard Biener
2021-08-18 23:56                 ` H.J. Lu
2021-08-19  7:01                   ` Thomas Schwinge
2016-11-11 20:44 ` [PATCH 8/9] Introduce class function_reader (v4) David Malcolm
2016-11-23 20:15   ` Bernd Schmidt
2016-11-23 20:46     ` David Malcolm
2016-12-01 14:40   ` Bernd Schmidt
2016-12-01 21:43     ` David Malcolm
2016-12-02  1:27       ` [PATCH 8a/9] Introduce class function_reader (v6) David Malcolm
2016-12-02  1:27         ` [PATCH 8b/9] Add target-independent selftests of RTL function reader David Malcolm
2016-12-02 15:06           ` Bernd Schmidt
2016-12-05  5:55             ` Jeff Law
2016-12-02  1:27         ` [PATCH 8d/9] Add x86_64-specific selftests for " David Malcolm
2016-12-19 16:43           ` [PATCH] Add x86_64-specific selftests for RTL function reader (v2) David Malcolm
2017-01-03 16:47             ` PING " David Malcolm
2017-01-05  9:43               ` Uros Bizjak
2016-12-02  1:27         ` [PATCH 8c/9] Add aarch64-specific selftests for RTL function reader David Malcolm
2016-12-06 17:22           ` James Greenhalgh
2016-12-06 19:38             ` David Malcolm
2016-12-07  9:30               ` James Greenhalgh
2016-12-02  1:28         ` [PATCH 9/9] Add "__RTL" to cc1 (v6) David Malcolm
2016-12-02 14:41         ` [PATCH 8a/9] Introduce class function_reader (v6) Bernd Schmidt
2016-12-02 18:12           ` [PATCH 8a/9] Introduce class function_reader (v7) David Malcolm
2016-12-02 18:58             ` Bernd Schmidt
2016-12-08  2:29               ` [PATCH] Avoid double unread_char (c) in patch 8a of RTL frontend David Malcolm
2016-12-08 15:16                 ` Bernd Schmidt
2016-12-08 20:06             ` [PATCH] Fix bug in MEM parsing in patches 8a/8b David Malcolm
2016-12-08 20:08               ` Bernd Schmidt
2016-12-09  1:29                 ` [PATCH] Prevent use of MEM_* attr accessor macros as lvalues David Malcolm
2016-12-09  1:32                   ` Bernd Schmidt
2016-12-19 22:15               ` [PATCH] Fix bug in MEM parsing in patches 8a/8b Jeff Law
2016-12-19 23:02                 ` David Malcolm
2016-12-02 15:28       ` [PATCH 8/9] Introduce class function_reader (v4) Bernd Schmidt
2016-12-02 19:51         ` [PATCH] Add ASSERT_RTX_PTR_EQ David Malcolm
2016-12-06 12:09           ` Bernd Schmidt
2016-11-11 20:44 ` [PATCH 6/9] Split class rtx_reader into md_reader vs rtx_reader David Malcolm
2016-11-22 21:26   ` Richard Sandiford
2016-11-11 20:44 ` [PATCH 4/9] (approved) Add some functions for use by the RTL frontend David Malcolm
2016-11-23 20:11   ` Jeff Law
2016-11-11 20:44 ` [PATCH 7/9] Add RTL-error-handling to host David Malcolm
2016-11-22 21:29   ` Richard Sandiford
2016-11-28 13:47   ` Bernd Schmidt
2016-11-29 17:20     ` David Malcolm
2016-11-29 17:23       ` Bernd Schmidt
2016-11-29 18:53         ` David Malcolm
2016-11-29 21:13           ` Bernd Schmidt
2016-11-30 16:18             ` Bernd Schmidt
2016-11-30 19:51               ` [PATCH] Minimal reimplementation of errors.c within read-md.c David Malcolm
2016-12-01 12:40                 ` Bernd Schmidt
2016-12-02 22:34                   ` [PATCH] Even more minimal " David Malcolm
2016-12-06 12:11                     ` Bernd Schmidt
2016-11-11 20:44 ` [PATCH 9/9] Add "__RTL" to cc1 (v4) David Malcolm
2016-11-14 15:14   ` Richard Biener
2016-11-15 21:07     ` David Malcolm
2016-11-16 13:24       ` Richard Biener
2016-11-18 21:02         ` [PATCH] Add "__RTL" to cc1 (v5) David Malcolm
2016-11-18 22:14           ` Joseph Myers
2016-11-18 22:46             ` [PATCH] Handle EOF in c_parser_parse_rtl_body David Malcolm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1478898935-46932-4-git-send-email-dmalcolm@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).