From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 0EACF3857C5B; Thu, 21 Oct 2021 15:01:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0EACF3857C5B Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/casm-refactoring-v4)] Fix GGC machinery. X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/casm-refactoring-v4 X-Git-Oldrev: 562caac65d81b75cb3085cd6ffd89b6723fe8d85 X-Git-Newrev: 33192e812b43409c9f01ed1fd618289bb25e2513 Message-Id: <20211021150102.0EACF3857C5B@sourceware.org> Date: Thu, 21 Oct 2021 15:01:02 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2021 15:01:02 -0000 https://gcc.gnu.org/g:33192e812b43409c9f01ed1fd618289bb25e2513 commit 33192e812b43409c9f01ed1fd618289bb25e2513 Author: Martin Liska 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 (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)); } + +/* 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 (); 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 (); 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
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::create_ggc (31); @@ -6560,13 +6560,7 @@ asm_out_state::asm_out_state () const_desc_htab = hash_table::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 (); - state->init_sections (); - return state; + return new (ggc_alloc ()) asm_out_state (); } enum tls_model