public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/casm-refactoring-v5)] Fix GGC machinery.
@ 2021-10-22 13:02 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-10-22 13:02 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:dd8c023faecc29205bf854bdd4c6f499507202d0

commit dd8c023faecc29205bf854bdd4c6f499507202d0
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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-22 13:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 13:02 [gcc(refs/users/marxin/heads/casm-refactoring-v5)] Fix GGC machinery Martin Liska

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).