From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id ACAD83858434 for ; Fri, 5 Nov 2021 14:27:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ACAD83858434 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6BF751FD36; Fri, 5 Nov 2021 14:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1636122458; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L0ZEPn6oBzxLYWxViLVBO9Hdv8NtgohOZtJVZBwLcn0=; b=hfMzxAUFARazzk5tipN8BLBBEXYCvB2QcTwWipzPcv/xMhSbmA1HIbk8/mTboVkjOAWcN2 JQhCNk+bZp8DUzLzXTQwnMkEKJYeGqI4eFwIe0ZR6xWiZ2oRlw//JDuMZ2BDo7laRXVkwW 85mIoFqq4K9axz+QWe2Ek9Bah6DC3kQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1636122458; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L0ZEPn6oBzxLYWxViLVBO9Hdv8NtgohOZtJVZBwLcn0=; b=ZS83LQt6V/APXeTnqVv0xrRk5ZATkmju9gXfDXI90FEJXpqEzVV/pU7MEiG/WwdYAggfu7 Ze6w/2PayGaSvwAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5617C1400B; Fri, 5 Nov 2021 14:27:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id AZIMFFo/hWH6BwAAMHmgww (envelope-from ); Fri, 05 Nov 2021 14:27:38 +0000 Message-ID: Date: Fri, 5 Nov 2021 15:27:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH 3/N] Come up with casm global state. Content-Language: en-US To: Richard Biener , Segher Boessenkool Cc: GCC Patches References: <8aa1fb10-334d-aa62-13e4-2ebc24d4ea16@suse.cz> <6a4d22df-d810-ea08-4782-6d79cc639e1b@suse.cz> <460ab511-289b-f82b-0b34-d16ddf581252@suse.cz> <856ae6d3-d1f7-4f00-0af0-afeb55a46f06@suse.cz> <20211021154028.GT614@gate.crashing.org> <20211025163047.GV614@gate.crashing.org> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2021 14:27:41 -0000 On 10/26/21 09:45, Richard Biener wrote: > On Mon, Oct 25, 2021 at 6:32 PM Segher Boessenkool > wrote: >> >> Hi! >> >> On Mon, Oct 25, 2021 at 03:36:25PM +0200, Martin Liška wrote: >>> --- a/gcc/config/rs6000/rs6000-internal.h >>> +++ b/gcc/config/rs6000/rs6000-internal.h >>> @@ -189,4 +189,13 @@ 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 (); >>> +}; >> >> Our coding convention says to use "class", not "struct" (since this >> isn't valid C code at all). >> >>> - sdata2_section >>> + sec.sdata2 >>> = get_unnamed_section (SECTION_WRITE, output_section_asm_op, >>> SDATA2_SECTION_ASM_OP); >> >> (broken indentation) >> >>> +/* Implement TARGET_ASM_INIT_SECTIONS. */ >> >> That comment is out-of-date. >> >>> +static asm_out_state * >>> +rs6000_elf_asm_init_sections (void) >>> +{ >>> + rs6000_asm_out_state *target_state >>> + = new (ggc_alloc ()) rs6000_asm_out_state (); >> >> Hrm, maybe we can have a macro or function that does this, ggc_new or >> something? >> >>> +/* Implement TARGET_ASM_INIT_SECTIONS. */ >>> + >>> +static asm_out_state * >>> +rs6000_xcoff_asm_init_sections (void) >> >> Here, too. Both implementations are each one of several functions that >> together implement the target macro. >> >>> + /* The section that holds the DWARF2 frame unwind information, when known. >>> + 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. */ >> >> Nothing here? Just remove the comment header? >> >> The idea looks fine to me. > > Yeah, of course then the target hook does not need to do the allocation > and we could simply keep the current init_sections hook but change it > to take the asm_out_state to initialize as argument. Makes sense. > > Note that I'd put > > + /* 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; > > into a union, thus > > union { > struct /* RS6000 sections */ { > /* ELF sections. */ > section *toc; > ... > } rs6000; > struct /* darwin sections */ { > ... > }; Union is a bit tricky for GGC marking script, but we can manage that. > > not sure whether we need some magic GTY marking here to make > it pick up the 'correct' set. Another alternative would be > > section *target[MAX_TARGET_SECTIONS]; > > and #defines in the targets mapping the former global variables to > indices in that array. > > All of this isn't "nice C++" of course, but well ... I'm not the one > to insist ;) Anyway, I took a look at targets that do call the init_sections hook and I noticed Darwin uses pretty many sections and comes up with an array that is defined here: ./gcc/config/darwin-sections.def I tend to creating all sections in asm_out_state with DEF_SECTION, where the list will be extensible with a target-specific definition list. What do you think Richi? Thanks, Martin > > Richard. > >> >> Segher