public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/marxin/heads/casm-refactoring-v4)] Fix GGC machinery.
Date: Thu, 21 Oct 2021 15:01:02 +0000 (GMT)	[thread overview]
Message-ID: <20211021150102.0EACF3857C5B@sourceware.org> (raw)

https://gcc.gnu.org/g:33192e812b43409c9f01ed1fd618289bb25e2513

commit 33192e812b43409c9f01ed1fd618289bb25e2513
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Oct 21 16:52:58 2021 +0200

    Fix GGC machinery.

Diff:
---
 gcc/config/rs6000/rs6000-internal.h | 25 ----------------------
 gcc/config/rs6000/rs6000.c          |  9 ++++----
 gcc/output.h                        | 41 ++++++++++++++++++++++++++++++++-----
 gcc/varasm.c                        | 17 ++++-----------
 4 files changed, 44 insertions(+), 48 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-internal.h b/gcc/config/rs6000/rs6000-internal.h
index 5d28b80dd77..f3312dc093c 100644
--- a/gcc/config/rs6000/rs6000-internal.h
+++ b/gcc/config/rs6000/rs6000-internal.h
@@ -189,31 +189,6 @@ extern bool rs6000_passes_vector;
 extern bool rs6000_returns_struct;
 extern bool cpu_builtin_p;
 
-struct rs6000_asm_out_state : public asm_out_state
-{
-  /* Initialize ELF sections. */
-  void init_elf_sections ();
-
-  /* Initialize XCOFF sections. */
-  void init_xcoff_sections ();
-
-  struct
-  {
-    /* ELF sections.  */
-    section *toc;
-    section *sdata2;
-
-    /* XCOFF sections.  */
-    section *read_only_data;
-    section *private_data;
-    section *tls_data;
-    section *tls_private_data;
-    section *read_only_private_data;
-  } target_sec;
-};
-
-extern GTY(()) rs6000_asm_out_state *target_casm;
-
 #define rs6000_casm static_cast<rs6000_asm_out_state *> (casm)
 
 #endif
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 0faf9d1388f..f463ad393b0 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -20625,6 +20625,10 @@ rs6000_ms_bitfield_layout_p (const_tree record_type)
     || lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (record_type));
 }
 \f
+
+/* Target CASM state used for GGC memory.  */
+static GTY(()) rs6000_asm_out_state *target_casm;
+
 #ifdef USING_ELFOS_H
 
 /* A get_unnamed_section callback, used for switching to toc_section.  */
@@ -20676,9 +20680,6 @@ rs6000_elf_output_toc_section_asm_op (const void *data ATTRIBUTE_UNUSED)
     }
 }
 
-/* Target CASM state used for GGC memory.  */
-rs6000_asm_out_state *target_casm;
-
 /* Initialize ELF sections. */
 
 void
@@ -20700,7 +20701,6 @@ rs6000_elf_asm_init_sections (void)
   rs6000_asm_out_state *target_state
     = new (ggc_alloc<rs6000_asm_out_state> ()) rs6000_asm_out_state ();
   target_state->init_elf_sections ();
-  target_state->init_sections ();
 
   return target_state;
 }
@@ -21440,7 +21440,6 @@ rs6000_xcoff_asm_init_sections (void)
   rs6000_asm_out_state *target_state
     = new (ggc_alloc<rs6000_asm_out_state> ()) rs6000_asm_out_state ();
   target_state->init_xcoff_sections ();
-  target_state->init_sections ();
 
   return target_state;
 }
diff --git a/gcc/output.h b/gcc/output.h
index 099abed91a1..56b95d6e89c 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -321,15 +321,18 @@ struct section_hasher : ggc_ptr_hash<section>
   static bool equal (section *, const char *);
 };
 
+enum asm_out_state_type
+{
+  DEFAULT,
+  RS6000
+};
+
 /* Assembly output state.  */
 
-struct GTY(()) asm_out_state
+struct GTY((desc ("%h.type"), tag ("DEFAULT"))) asm_out_state
 {
   /* Default constructor.  */
-  asm_out_state ();
-
-  /* Initialize all sections in SEC variable.  */
-  void init_sections (void);
+  asm_out_state (asm_out_state_type t = DEFAULT);
 
   /* Assembly output stream.  */
   FILE * GTY((skip)) out_file;
@@ -379,6 +382,9 @@ struct GTY(()) asm_out_state
   /* True if code for the current function is currently being directed
      at the cold section.  */
   bool in_cold_section_p;
+
+  /* Type used by GGC.  */
+  ENUM_BITFIELD (asm_out_state_type) type : 8;
 };
 
 extern GTY(()) asm_out_state *casm;
@@ -386,6 +392,31 @@ extern GTY(()) asm_out_state *casm;
 /* Helper macro for commonly used accesses.  */
 #define asm_out_file casm->out_file
 
+struct GTY((tag ("RS6000"))) rs6000_asm_out_state : public asm_out_state
+{
+  rs6000_asm_out_state (): asm_out_state (RS6000), target_sec ({}) {}
+
+  /* Initialize ELF sections. */
+  void init_elf_sections ();
+
+  /* Initialize XCOFF sections. */
+  void init_xcoff_sections ();
+
+  struct
+  {
+    /* ELF sections.  */
+    section *toc;
+    section *sdata2;
+
+    /* XCOFF sections.  */
+    section *read_only_data;
+    section *private_data;
+    section *tls_data;
+    section *tls_private_data;
+    section *read_only_private_data;
+  } target_sec;
+};
+
 /* The first global object in the file.  */
 extern const char *first_global_object_name;
 
diff --git a/gcc/varasm.c b/gcc/varasm.c
index ae2d960104b..c9d907d8bc2 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6550,9 +6550,9 @@ make_decl_one_only (tree decl, tree comdat_group)
 
 /* Default constructor.  */
 
-asm_out_state::asm_out_state ()
+asm_out_state::asm_out_state (asm_out_state_type t)
 : out_file (NULL), in_section (NULL),
-  sec ({}), anchor_labelno (0), in_cold_section_p (false)
+  sec ({}), anchor_labelno (0), in_cold_section_p (false), type (t)
 {
   section_htab = hash_table<section_hasher>::create_ggc (31);
 
@@ -6560,13 +6560,7 @@ asm_out_state::asm_out_state ()
   const_desc_htab = hash_table<tree_descriptor_hasher>::create_ggc (1009);
 
   shared_constant_pool = create_constant_pool ();
-}
-
 
-/* Initialize all sections in SEC variable.  */
-void
-asm_out_state::init_sections (void)
-{
 #ifdef TEXT_SECTION_ASM_OP
   sec.text = get_unnamed_section (SECTION_CODE, output_section_asm_op,
 				  TEXT_SECTION_ASM_OP);
@@ -6621,8 +6615,7 @@ asm_out_state::init_sections (void)
 					   emit_bss);
 #endif
 
-  if (sec.readonly_data == NULL)
-    sec.readonly_data = sec.text;
+  sec.readonly_data = sec.text;
 }
 
 void
@@ -6640,9 +6633,7 @@ init_varasm_once (void)
 asm_out_state *
 default_init_sections (void)
 {
-  asm_out_state *state = new (ggc_alloc<asm_out_state> ()) asm_out_state ();
-  state->init_sections ();
-  return state;
+  return new (ggc_alloc<asm_out_state> ()) asm_out_state ();
 }
 
 enum tls_model


             reply	other threads:[~2021-10-21 15:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 15:01 Martin Liska [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-10-21 14:54 Martin Liska

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=20211021150102.0EACF3857C5B@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@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).