public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/casm-refactoring-v5)] Remove complex inheritance.
@ 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:13cb235314f14c8b716c69ed781be6615b1c55df

commit 13cb235314f14c8b716c69ed781be6615b1c55df
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Oct 22 15:01:33 2021 +0200

    Remove complex inheritance.

Diff:
---
 gcc/config/rs6000/rs6000-internal.h |  9 ++++++-
 gcc/config/rs6000/rs6000-logue.c    |  2 +-
 gcc/config/rs6000/rs6000.c          | 37 +++++++++++++--------------
 gcc/output.h                        | 51 +++++++++++--------------------------
 gcc/varasm.c                        |  4 +--
 5 files changed, 43 insertions(+), 60 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-internal.h b/gcc/config/rs6000/rs6000-internal.h
index f3312dc093c..d5cde365947 100644
--- a/gcc/config/rs6000/rs6000-internal.h
+++ b/gcc/config/rs6000/rs6000-internal.h
@@ -189,6 +189,13 @@ extern bool rs6000_passes_vector;
 extern bool rs6000_returns_struct;
 extern bool cpu_builtin_p;
 
-#define rs6000_casm static_cast<rs6000_asm_out_state *> (casm)
+struct rs6000_asm_out_state : public asm_out_state
+{
+  /* Initialize ELF sections. */
+  void init_elf_sections ();
+
+  /* Initialize XCOFF sections. */
+  void init_xcoff_sections ();
+};
 
 #endif
diff --git a/gcc/config/rs6000/rs6000-logue.c b/gcc/config/rs6000/rs6000-logue.c
index 7a078817fe3..0a087cbd5e4 100644
--- a/gcc/config/rs6000/rs6000-logue.c
+++ b/gcc/config/rs6000/rs6000-logue.c
@@ -5506,7 +5506,7 @@ rs6000_output_function_epilogue (FILE *file)
       need_toc_init = 0;
       if (!toc_initialized)
 	{
-	  switch_to_section (rs6000_casm->target_sec.toc);
+	  switch_to_section (casm->sec.toc);
 	  switch_to_section (current_function_section ());
 	}
     }
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index f463ad393b0..9de3ed9611d 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -14739,7 +14739,7 @@ rs6000_assemble_integer (rtx x, unsigned int size, int aligned_p)
 	 section.  */
       if (DEFAULT_ABI == ABI_V4
 	  && (TARGET_RELOCATABLE || flag_pic > 1)
-	  && casm->in_section != rs6000_casm->target_sec.toc
+	  && casm->in_section != casm->sec.toc
 	  && !recurse
 	  && !CONST_SCALAR_INT_P (x)
 	  && CONSTANT_P (x))
@@ -20626,9 +20626,6 @@ rs6000_ms_bitfield_layout_p (const_tree 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.  */
@@ -20685,10 +20682,10 @@ rs6000_elf_output_toc_section_asm_op (const void *data ATTRIBUTE_UNUSED)
 void
 rs6000_asm_out_state::init_elf_sections ()
 {
-  target_sec.toc
+  sec.toc
     = get_unnamed_section (0, rs6000_elf_output_toc_section_asm_op, NULL);
 
- target_sec.sdata2
+ sec.sdata2
     = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
 			   SDATA2_SECTION_ASM_OP);
 }
@@ -20712,7 +20709,7 @@ rs6000_elf_select_rtx_section (machine_mode mode, rtx x,
 			       unsigned HOST_WIDE_INT align)
 {
   if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x, mode))
-    return rs6000_casm->target_sec.toc;
+    return casm->sec.toc;
   else
     return default_elf_select_rtx_section (mode, x, align);
 }
@@ -21403,30 +21400,30 @@ rs6000_xcoff_output_toc_section_asm_op (const void *data ATTRIBUTE_UNUSED)
 void
 rs6000_asm_out_state::init_xcoff_sections ()
 {
-  target_sec.read_only_data
+  sec.read_only_data
     = get_unnamed_section (0, rs6000_xcoff_output_readonly_section_asm_op,
 			   &xcoff_read_only_section_name);
 
-  target_sec.private_data
+  sec.private_data
     = get_unnamed_section (SECTION_WRITE,
 			   rs6000_xcoff_output_readwrite_section_asm_op,
 			   &xcoff_private_data_section_name);
 
-  target_sec.read_only_private_data
+  sec.read_only_private_data
     = get_unnamed_section (0, rs6000_xcoff_output_readonly_section_asm_op,
 			   &xcoff_private_rodata_section_name);
 
-  target_sec.tls_data
+  sec.tls_data
     = get_unnamed_section (SECTION_TLS,
 			   rs6000_xcoff_output_tls_section_asm_op,
 			   &xcoff_tls_data_section_name);
 
-  target_sec.tls_private_data
+  sec.tls_private_data
     = get_unnamed_section (SECTION_TLS,
 			   rs6000_xcoff_output_tls_section_asm_op,
 			   &xcoff_private_data_section_name);
 
-  target_sec.toc
+  sec.toc
     = get_unnamed_section (0, rs6000_xcoff_output_toc_section_asm_op, NULL);
 
   sec.readonly_data = target_sec.read_only_data;
@@ -21509,9 +21506,9 @@ rs6000_xcoff_select_section (tree decl, int reloc,
   if (decl_readonly_section (decl, reloc))
     {
       if (TREE_PUBLIC (decl))
-	return rs6000_casm->target_sec.read_only_data;
+	return casm->sec.read_only_data;
       else
-	return rs6000_casm->target_sec.read_only_private_data;
+	return casm->sec.read_only_private_data;
     }
   else
     {
@@ -21530,7 +21527,7 @@ rs6000_xcoff_select_section (tree decl, int reloc,
 	if (TREE_PUBLIC (decl))
 	return casm->sec.data;
       else
-	return rs6000_casm->target_sec.private_data;
+	return casm->sec.private_data;
     }
 }
 
@@ -21555,9 +21552,9 @@ rs6000_xcoff_select_rtx_section (machine_mode mode, rtx x,
 				 unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
 {
   if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x, mode))
-    return rs6000_casm->target_sec.toc;
+    return casm->sec.toc;
   else
-    return rs6000_casm->target_sec.read_only_private_data;
+    return casm->sec.read_only_private_data;
 }
 
 /* Remove any trailing [DS] or the like from the symbol name.  */
@@ -21631,8 +21628,8 @@ rs6000_xcoff_file_start (void)
   output_quoted_string (asm_out_file, main_input_filename);
   fputc ('\n', asm_out_file);
   if (write_symbols != NO_DEBUG)
-    switch_to_section (rs6000_casm->target_sec.private_data);
-  switch_to_section (rs6000_casm->target_sec.toc);
+    switch_to_section (casm->sec.private_data);
+  switch_to_section (casm->sec.toc);
   switch_to_section (casm->sec.text);
   if (profile_flag)
     fprintf (asm_out_file, "\t.extern %s\n", RS6000_MCOUNT);
diff --git a/gcc/output.h b/gcc/output.h
index 56b95d6e89c..ec9cda42500 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -321,18 +321,12 @@ 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((desc ("%h.type"), tag ("DEFAULT"))) asm_out_state
+struct GTY(()) asm_out_state
 {
   /* Default constructor.  */
-  asm_out_state (asm_out_state_type t = DEFAULT);
+  asm_out_state ();
 
   /* Assembly output stream.  */
   FILE * GTY((skip)) out_file;
@@ -374,6 +368,19 @@ struct GTY((desc ("%h.type"), tag ("DEFAULT"))) asm_out_state
        The section is set either by the target's init_sections hook or by the
        first call to switch_to_eh_frame_section.  */
     section *eh_frame;
+
+    /* RS6000 sections.  */
+
+    /* 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;
   } sec;
 
   /* The next number to use for internal anchor labels.  */
@@ -382,9 +389,6 @@ struct GTY((desc ("%h.type"), tag ("DEFAULT"))) 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;
@@ -392,31 +396,6 @@ 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 c9d907d8bc2..bb95e34fc36 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_type t)
+asm_out_state::asm_out_state ()
 : out_file (NULL), in_section (NULL),
-  sec ({}), anchor_labelno (0), in_cold_section_p (false), type (t)
+  sec ({}), anchor_labelno (0), in_cold_section_p (false)
 {
   section_htab = hash_table<section_hasher>::create_ggc (31);


^ 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)] Remove complex inheritance 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).