From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id F3F2C385840B for ; Tue, 5 Oct 2021 11:54:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F3F2C385840B Received: by mail-ed1-x52a.google.com with SMTP id g10so17667990edj.1 for ; Tue, 05 Oct 2021 04:54:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=NBiyj4BMH9XfI27YnigUMY8cOyoT5/DzPFSCNuoyTJA=; b=He1dsk/ut8ugukzfXQb0GAhol95FXVforwuMKe2oUPxRIEMxfx0Ojyx1V1zoRdLpoF tsp7z8b/MiDku98m+L9WkeffiaOWGpmJs8Bur4JSeL5ZYUyEXxUR8PlNsIJpjLuIGgqN o5vR8A8MzlJVEZy2vitxBxFV0hJjiwMh/jdZe+k+Sq4MaRaXIME7GDqxv1nw71irzLSF ksi+SDCKlS5ULMLkxLuqsqcZ+SuwEEe2BOO04+WOTKCMHJN7b3DaohwzsxMp1Ey11TFb 7EWvCER4Oy++k1M0m88nIVFvdanZD6uCdIdko9VF7yXFl5D+FCaeGHf+KbEoma1xPaoP 4tyQ== X-Gm-Message-State: AOAM533wgfxsSKd32tEK4e5u5H6dg4Ae8+0PiCArojKH97er5FuUvKec As5Nwnkv321bnz6swJ/NkmFrbgeyztTSZUXZqGA= X-Google-Smtp-Source: ABdhPJy5MbPaheBOKVtFiMrpJYJw44zNI3oNcRSjbXZFWrlcQ7SWMFNCehv0gSYZLo4m0xvE0VYT5vjii4yG90etN/w= X-Received: by 2002:aa7:c78f:: with SMTP id n15mr26047849eds.338.1633434885442; Tue, 05 Oct 2021 04:54:45 -0700 (PDT) MIME-Version: 1.0 References: <8aa1fb10-334d-aa62-13e4-2ebc24d4ea16@suse.cz> <6a4d22df-d810-ea08-4782-6d79cc639e1b@suse.cz> <460ab511-289b-f82b-0b34-d16ddf581252@suse.cz> In-Reply-To: <460ab511-289b-f82b-0b34-d16ddf581252@suse.cz> From: Richard Biener Date: Tue, 5 Oct 2021 13:54:34 +0200 Message-ID: Subject: Re: [PATCH 3/N] Come up with casm global state. To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, 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: Tue, 05 Oct 2021 11:54:51 -0000 On Mon, Oct 4, 2021 at 1:13 PM Martin Li=C5=A1ka wrote: > > On 9/22/21 11:59, Richard Biener wrote: > > On Thu, Sep 16, 2021 at 3:12 PM Martin Li=C5=A1ka wrot= e: > >> > >> This patch comes up with asm_out_state and a new global variable casm. > >> > >> Tested on all cross compilers. > >> Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > >> > >> Ready to be installed? > > > > * output.h (struct asm_out_file): New struct that replaces a > > ^^^ > > asm_out_state? > > Yes, sure! > > > > > You replace a lot of asm_out_file - do we still need the macro then? > > (I'd have simplified the patch leaving that replacement out at first) > > Well, I actually replaced only a very small fraction of the usage of asm_= out_file. > > $ git grep asm_out_file | grep -v ChangeLog | wc -l > > 1601 > > > So I think we should live with the macro for some time ... > > > > > You leave quite some global state out of the struct that is obviously > > related, in the diff I see object_block_htab for example. > > Yes, I'm aware of it. Can we do that incrementally? > > > Basically > > everything initialized in init_varasm_once is a candidate (which > > then shows const_desc_htab and shared_constant_pool as well > > as pending_assemble_externals_set). > > Well, these would probably need a different header file (or another #incl= ude ... must > be added before output.h :// ). > > > For the goal of outputting > > early DWARF to another file the state CTOR could have a mode > > to not initialize those parts or we could have asm-out-state-with-secti= ons > > as base of asm-out-state. > > Yes, right now asm_out_state ctor is minimal: > > asm_out_state (): out_file (NULL), in_section (NULL), > sec ({}), anchor_labelno (0), in_cold_section_p (false) > { > section_htab =3D hash_table::create_ggc (31); > } > > > > > In the end there will be a target part of the state so I think > > construction needs to be defered to the target which can > > derive from asm-out-state and initialize the part it needs. > > That's currently what targetm.asm_out.init_sections () does > > and we'd transform that to a targetm.asm_out.create () or so. > > That might already be necessary for the DWARF stuff. > > So what do you want to with content of init_varasm_once function? It goes away ;) Or rather becomes the invocation of the asm-out-state CTOR via the target hook. > > > > That said, dealing with the target stuff piecemail is OK, but maybe > > try to make sure that init_varasm_once is actually identical > > to what the CTOR does? > > So you want asm_out_state::asm_out_state doing what we current initialize > in init_varasm_once, right? Yes, asm_out_state should cover everything initialized in init_varasm_once (and the called targetm.asm_out.init_sections). targetm.asm_out.init_sections would become asm_out_state *init_sections (); where the target can derive from asm_out_state (optionally) and allocates the asm-out-state & invokes the CTORs. The middle-end visible asm_out_state would contain all the tables initialized in init_varasm_once. I'm not sure if doing it piecemail is good - we don't want to touch things multiple times without good need and it might be things turn out not be as "simple" as the above plan sounds. I would suggest to try the conversion with powerpc since it seems to be the only target with two different implementations for the target hook. The static GTY(()) section *read_only_data_section; static GTY(()) section *private_data_section; static GTY(()) section *tls_data_section; static GTY(()) section *tls_private_data_section; static GTY(()) section *read_only_private_data_section; static GTY(()) section *sdata2_section; section *toc_section =3D 0; could become #defines to static_cast (casm)->section_name and there'd be class rs6000_asm_out_state : public asm_out_state { ... add stuff ... } in rs6000/xcoff.h and rs6000/sysv4.h and some generic rs6000 header as well (adding no fields) and the target hook would basically do return ggc_new rs6000_asm_state (); (OK, ggc_alloc + placement new I guess). The default hook just creates asm_out_state. Richard. > Thanks, > Cheers, > Martin > > > > > > Richard. > > > >> Thanks, > >> Martin >