From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe29.google.com (mail-vs1-xe29.google.com [IPv6:2607:f8b0:4864:20::e29]) by sourceware.org (Postfix) with ESMTPS id E4559385558C for ; Fri, 15 Sep 2023 23:27:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4559385558C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.washington.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.washington.edu Received: by mail-vs1-xe29.google.com with SMTP id ada2fe7eead31-450f6775dccso1335743137.1 for ; Fri, 15 Sep 2023 16:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1694820451; x=1695425251; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5Zw1UHkcdX4TWJvLPKL41V+2l8zxLotU1kgZmzpkPro=; b=HmkFwzdpJa/RXay1PJPGbpldb6OnJR6gmDfxlbWRVo46V+rRw7B9xTDJ2eI/tJwtTN Hh9K0S2bQNQzcilGYwrpHQpXjpk5d6GRqi0iMf4xlAiZQbBALmV7StxxMdk6x+bjxVky u3s5mqxQpNkZ1IIzL0qql7W7WE3UhHskttsno= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694820451; x=1695425251; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Zw1UHkcdX4TWJvLPKL41V+2l8zxLotU1kgZmzpkPro=; b=r8t6+SRj8WuCAvhy94sape9aagI1ig8KE9luyy6uul3Mbvw1HvmAMi565OvBNPwjgD ZYsWGBbLLeUGSdWRKVNk/mVjVpVZCdb5LPXnSpcPfJE5O9ttmRS9nDmEKEo3PJBu6bVm DUbAcZdO55cc0rBWT6nhX/zO8vDlkyJujDl5sozCiZOwE95RDwUNvBl3PWT+fwyz8twI Yfsv4H9W+IDIJ6HSofD8Nrlqsm6biaD96aOd5QxRhB1+f1CRv5FP8vj0JWxWnC/YvKYe INXvmZunFjhbL0VVxiTBxDO///leczzNOonW27ddTuii2asp4hHjCbpfSn/BAEZBTSnu bAyQ== X-Gm-Message-State: AOJu0YzXcVqJgFXKnoazRcG9gI8ij8MXVXKJvE95uMm+Z58u0hz+KAVq oz2YGCgbgHymLltpttiS55nDivkQX8RLLSePoY4aow== X-Google-Smtp-Source: AGHT+IG85SHtMJCLH13AdEnf22QN7Y9VHNASu6vTx2TMufSeD5okSOnj+lo0Pjo2bduc+7rxJQvhMMtmCPQbkOqvtEo= X-Received: by 2002:a67:f912:0:b0:44d:4d7f:bcc2 with SMTP id t18-20020a67f912000000b0044d4d7fbcc2mr3596202vsq.12.1694820451124; Fri, 15 Sep 2023 16:27:31 -0700 (PDT) MIME-Version: 1.0 References: <20230914064949.29787-1-kmatsui@gcc.gnu.org> <20230914064949.29787-17-kmatsui@gcc.gnu.org> <308093c9-bc0-49b-36ce-8687612ffd88@codesourcery.com> In-Reply-To: <308093c9-bc0-49b-36ce-8687612ffd88@codesourcery.com> From: Ken Matsui Date: Fri, 15 Sep 2023 16:26:55 -0700 Message-ID: Subject: Re: [PATCH v11 16/40] c, c++: Use 16 bits for all use of enum rid for more keyword space To: Joseph Myers Cc: Ken Matsui , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Sep 14, 2023 at 10:54=E2=80=AFAM Joseph Myers wrote: > > On Wed, 13 Sep 2023, Ken Matsui via Gcc-patches wrote: > > > diff --git a/gcc/c/c-parser.h b/gcc/c/c-parser.h > > index 545f0f4d9eb..eed6deaf0f8 100644 > > --- a/gcc/c/c-parser.h > > +++ b/gcc/c/c-parser.h > > @@ -51,14 +51,14 @@ enum c_id_kind { > > /* A single C token after string literal concatenation and conversion > > of preprocessing tokens to tokens. */ > > struct GTY (()) c_token { > > + /* If this token is a keyword, this value indicates which keyword. > > + Otherwise, this value is RID_MAX. */ > > + ENUM_BITFIELD (rid) keyword : 16; > > /* The kind of token. */ > > ENUM_BITFIELD (cpp_ttype) type : 8; > > /* If this token is a CPP_NAME, this value indicates whether also > > declared as some kind of type. Otherwise, it is C_ID_NONE. */ > > ENUM_BITFIELD (c_id_kind) id_kind : 8; > > - /* If this token is a keyword, this value indicates which keyword. > > - Otherwise, this value is RID_MAX. */ > > - ENUM_BITFIELD (rid) keyword : 8; > > /* If this token is a CPP_PRAGMA, this indicates the pragma that > > was seen. Otherwise it is PRAGMA_NONE. */ > > ENUM_BITFIELD (pragma_kind) pragma_kind : 8; > > If you want to optimize layout, I'd expect flags to move so it can share > the same 32-bit unit as the pragma_kind bit-field (not sure if any change= s > should be made to the declaration of flags to maximise the chance of such > sharing across different host bit-field ABIs). > > > diff --git a/gcc/cp/parser.h b/gcc/cp/parser.h > > index 6cbb9a8e031..3c3c482c6ce 100644 > > --- a/gcc/cp/parser.h > > +++ b/gcc/cp/parser.h > > @@ -40,11 +40,11 @@ struct GTY(()) tree_check { > > /* A C++ token. */ > > > > struct GTY (()) cp_token { > > - /* The kind of token. */ > > - enum cpp_ttype type : 8; > > /* If this token is a keyword, this value indicates which keyword. > > Otherwise, this value is RID_MAX. */ > > - enum rid keyword : 8; > > + enum rid keyword : 16; > > + /* The kind of token. */ > > + enum cpp_ttype type : 8; > > /* Token flags. */ > > unsigned char flags; > > /* True if this token is from a context where it is implicitly exter= n "C" */ > > You're missing an update to the "3 unused bits." comment further down. > > > @@ -988,7 +988,7 @@ struct GTY(()) cpp_hashnode { > > unsigned int directive_index : 7; /* If is_directive, > > then index into directive tabl= e. > > Otherwise, a NODE_OPERATOR. *= / > > - unsigned int rid_code : 8; /* Rid code - for front ends. */ > > + unsigned int rid_code : 16; /* Rid code - for front e= nds. */ > > unsigned int flags : 9; /* CPP flags. */ > > ENUM_BITFIELD(node_type) type : 2; /* CPP node type. */ > > You're missing an update to the "5 bits spare." comment further down. > > Do you have any figures for the effects on compilation time or memory > usage from the increase in size of these structures? > Here is the benchmark result: https://github.com/ken-matsui/gsoc23/tree/main/reports/gcc-build I can see regression for compilation time but not for memory. * Time: +0.950995% * Memory: No difference proven at 95.0% confidence Sincerely, Ken Matsui > -- > Joseph S. Myers > joseph@codesourcery.com