From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 75A1E382FCB7 for ; Fri, 30 Jun 2023 16:11:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75A1E382FCB7 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.01,171,1684828800"; d="scan'208";a="11733160" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 30 Jun 2023 08:11:41 -0800 IronPort-SDR: H4s5DNVBQi7KgjdLtKs4cRI7KEwxPI1Ko6rqs7S4/CPy31s5f5xcD2DP+AmiWBWrlp+wN5W6BR Atzgc93TPjz695S57ONYa2GRgXG5HEYqB8Jn4rRP6Id4nEhq4wYkjUd1cOwmeuttJKlWyXezaj tEBjOBANBJz3pZnu+1l5BnWQs9P+iARwMjaXs+8SlsX3YoOewAKZgK18z3YnHyYMutNJY9nj1C GzFOGifUfQ52VSfAR8tfLxcoPi1zhZOk41V0vI9Z/Hw4A4rcgcsE5BtcrNzRA1suh33drYPdro Ipo= From: Thomas Schwinge To: Kito Cheng , Richard Biener , Jakub Jelinek CC: , , Bernhard Reutner-Fischer , , , , Subject: Re: Adjust LTO mode tables for "Machine_Mode: Extend machine_mode from 8 to 16 bits" (was: [PATCH] Machine_Mode: Extend machine_mode from 8 to 16 bits) In-Reply-To: References: <20230512050016.476110-1-pan2.li@intel.com> <2CEAD79B-D664-41B4-A337-5E77ECFB2F9D@gmail.com> <87o7kxuq9s.fsf@euler.schwinge.homeip.net> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Fri, 30 Jun 2023 18:11:33 +0200 Message-ID: <87h6qpc4lm.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi! On 2023-06-30T20:45:38+0800, Kito Cheng wrote: >> On 2023-05-13T16:44:41+0800, Kito Cheng via Gcc-patches wrote: >> > Tried this patch and I ran into some issues, some variables are using >> > unsigned char to hold machine mode and will have problems when the >> > number of modes is larger than 255... >> > >> > And here is the fix: >> >> > --- a/gcc/genmodes.cc >> > +++ b/gcc/genmodes.cc >> > @@ -1141,10 +1141,10 @@ inline __attribute__((__always_inline__))\n\ >> > #else\n\ >> > extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n= \ >> > #endif\n\ >> > -unsigned char\n\ >> > +unsigned short\n\ >> > mode_inner_inline (machine_mode mode)\n\ >> > {\n\ >> > - extern const unsigned char mode_inner[NUM_MACHINE_MODES];\n\ >> > + extern const unsigned short mode_inner[NUM_MACHINE_MODES];\n\ >> > gcc_assert (mode >=3D 0 && mode < NUM_MACHINE_MODES);\n\ >> > switch (mode)\n\ >> > {"); >> > @@ -1529,7 +1529,7 @@ emit_mode_wider (void) >> > int c; >> > struct mode_data *m; >> > >> > - print_decl ("unsigned char", "mode_next", "NUM_MACHINE_MODES"); >> > + print_decl ("unsigned short", "mode_next", "NUM_MACHINE_MODES"); >> >> Etc. >> >> Instead of 's%char%short', shouldn't we really be using >> 'enum machine_mode' here? (I understand such a change may require some >> further surgery, but wouldn't it be the correct thing to do?) > > Hmmm, I think maybe what we need is to leverage C++ language features > to declare enum with underlying types like that: > > enum machine_mode : uint16_t Eh, so that's the reason/confusion (or, at least some of it...) here: my (na=C3=AFve...) assumption has been that 'enum machine_mode' already does h= ave a fixed underlying type -- but apparently it does not, so defaults to 'unsigned int'! (gdb) ptype lto_mode_identity_table type =3D const enum machine_mode : unsigned int {E_VOIDmode, E_BLKmode,= E_CCmode, [...], NUM_MACHINE_MODES =3D 130} * So, yeah, should we fix that, and then generally use 'enum machine_mode' instead of 'char' vs. 'short'? (Or, which other "detail" do I fail to recognize this time?) Gr=C3=BC=C3=9Fe Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955