From patchwork Thu Sep 14 06:42:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ken Matsui X-Patchwork-Id: 139396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp172010vqi; Thu, 14 Sep 2023 00:30:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsfQTY/vPC+StcX1EKfO940p3LOH1hP0ocx2Jiy0T1wuk3G1IR6rUVleWW9baPPFGk3JJ9 X-Received: by 2002:a05:6512:2394:b0:4f8:71cc:2b6e with SMTP id c20-20020a056512239400b004f871cc2b6emr4796433lfv.33.1694676611319; Thu, 14 Sep 2023 00:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694676611; cv=none; d=google.com; s=arc-20160816; b=LPsWe4eJin9PKGtpHZIxrFed6+GKXOeVY0l5/yPrDS6INjy7ItMDcParO0RIdQ3Y8Q 2C6YpYeRuR4abiX5zyi7jSHUpVwr70uhVOhK+ami9Z6Wy5Ig0oZ7lR4I+qjQY8Gj7zLh w1WkULIsKeJULXiXsugaML3Mo5NT9jhBbb442lHyKKzYYKUbpYZLIpe8Uipe43Rv6oRm 5puacveRCH3imFusRRqoomXjRgsbq9VrGeuaDyqJam2D7ToKomObazcjbFdR5WvwpiQ6 lNR9HAx95b35dkVmS0WtsMoFEgk5bVKGPgQcDU/jb+Qo8484C0JNW9tSjxhovSwLjL5c SQ+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=FCLu+mz9+J3/O0l2Rv6Qn826fchOnhHPrSUlDMBpo7Q=; fh=kSSy/oyUXqQD15FLeKdymIgDBFPFITPA1Gj52CNOxRQ=; b=w8Z3JTM05gPTfXCw3oBOuhso+9F7+N2BUBuLJS/uUe+P6jGsLTfl5eDvW40z84f2/z l0D4iUKjRpNqoU+bWTbwNcVAC8DfcKIx8lYif6U1updk5Z7HxXcJ2pKlLWoXDq3R24FP Bx66cB3uwb6O4PQgisvF4o6wD1+ikqwSzIsvAUUDchTcsRMFHh8O7oqtqxL3d1ZqUOuY by65gP41JOkN6KUXcZOHwkKyKUOpvQSPnQV3+zofR0nYcVrSCqubaIc9YGt/cLbMMB51 94mCHseIpnuVS/VAnasdVBA0WT3ySKJsEYtYAiEoVH0wRLZkwFm03zr9q8DnzNvOy0aL xqlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pdsLHhmU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d15-20020a056402516f00b0052545f962cbsi916776ede.640.2023.09.14.00.30.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 00:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pdsLHhmU; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 272053959E46 for ; Thu, 14 Sep 2023 07:04:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 272053959E46 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694675095; bh=FCLu+mz9+J3/O0l2Rv6Qn826fchOnhHPrSUlDMBpo7Q=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=pdsLHhmUDgBSctVm5BfHoLWVGsZnojT4c8Zphv3L1jaTHyxbS8gsNqxbCabaZlM+X /g977faI3oV7skdemAdEbRU7HS2N+hx4asmLO043puo/giJvCQwAJ7m6xza/+l+xYO RXsAKD+IYIMniP62Vt7wkXco6BNYFNSmbutvPOXo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-00641c01.pphosted.com (mx0a-00641c01.pphosted.com [205.220.165.146]) by sourceware.org (Postfix) with ESMTPS id A89813856263; Thu, 14 Sep 2023 06:51:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A89813856263 Received: from pps.filterd (m0247475.ppops.net [127.0.0.1]) by mx0a-00641c01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38E6dCF2027958; Thu, 14 Sep 2023 06:51:16 GMT Received: from mxout26.s.uw.edu (mxout26.s.uw.edu [140.142.234.176]) by mx0a-00641c01.pphosted.com (PPS) with ESMTPS id 3t3ner2ba0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Sep 2023 06:51:16 +0000 Received: from smtp.washington.edu (smtp.washington.edu [140.142.234.157]) by mxout26.s.uw.edu (8.14.4+UW20.07/8.14.4+UW22.04) with ESMTP id 38E6oqWD006961 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Sep 2023 23:50:52 -0700 X-Auth-Received: from localhost.localdomain ([10.154.75.179]) (authenticated authid=kmatsui) by smtp.washington.edu (8.16.1+UW21.10/8.14.4+UW19.10) with ESMTPSA id 38E6nupd027316 (version=TLSv1.2 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 13 Sep 2023 23:50:52 -0700 X-UW-Orig-Sender: kmatsui@smtp.washington.edu To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Ken Matsui Subject: [PATCH v11 16/40] c, c++: Use 16 bits for all use of enum rid for more keyword space Date: Wed, 13 Sep 2023 23:42:55 -0700 Message-ID: <20230914064949.29787-17-kmatsui@gcc.gnu.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230914064949.29787-1-kmatsui@gcc.gnu.org> References: <20230914064949.29787-1-kmatsui@gcc.gnu.org> MIME-Version: 1.0 X-Proofpoint-GUID: cN3LZI3fYrtMbkoG4JHZQ4NrXasmOzV4 X-Proofpoint-ORIG-GUID: cN3LZI3fYrtMbkoG4JHZQ4NrXasmOzV4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-14_04,2023-09-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1034 impostorscore=0 malwarescore=0 suspectscore=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=910 adultscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309140060 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NEUTRAL, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ken Matsui via Gcc-patches From: Ken Matsui Reply-To: Ken Matsui Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776997222224492547 X-GMAIL-MSGID: 1776997222224492547 Now that RID_MAX has reached 255, we need to update the bit sizes of every use of the enum rid from 8 to 16 to support more keywords. gcc/c-family/ChangeLog: * c-indentation.h (struct token_indent_info): Make keyword 16 bits and move this upward to minimize memory fragmentation. gcc/c/ChangeLog: * c-parser.cc (c_parse_init): Handle RID_MAX not to exceed the max value of 16 bits. * c-parser.h (struct c_token): Make keyword 16 bits and move this upward to minimize memory fragmentation. gcc/cp/ChangeLog: * parser.h (struct cp_token): Make keyword 16 bits and move this upward to minimize memory fragmentation. (struct cp_lexer): Likewise, for saved_keyword. libcpp/ChangeLog: * include/cpplib.h (struct cpp_hashnode): Make rid_code 16 bits. Signed-off-by: Ken Matsui --- gcc/c-family/c-indentation.h | 2 +- gcc/c/c-parser.cc | 6 +++--- gcc/c/c-parser.h | 6 +++--- gcc/cp/parser.h | 8 ++++---- libcpp/include/cpplib.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gcc/c-family/c-indentation.h b/gcc/c-family/c-indentation.h index c0e07bf49f1..1ce8753813a 100644 --- a/gcc/c-family/c-indentation.h +++ b/gcc/c-family/c-indentation.h @@ -25,8 +25,8 @@ along with GCC; see the file COPYING3. If not see struct token_indent_info { location_t location; + ENUM_BITFIELD (rid) keyword : 16; ENUM_BITFIELD (cpp_ttype) type : 8; - ENUM_BITFIELD (rid) keyword : 8; }; /* Extract token information from TOKEN, which ought to either be a diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index b9a1b75ca43..2086f253923 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -115,9 +115,9 @@ c_parse_init (void) tree id; int mask = 0; - /* Make sure RID_MAX hasn't grown past the 8 bits used to hold the keyword in - the c_token structure. */ - gcc_assert (RID_MAX <= 255); + /* Make sure RID_MAX hasn't grown past the 16 bits used to hold the keyword + in the c_token structure. */ + gcc_assert (RID_MAX <= 65535); mask |= D_CXXONLY; if (!flag_isoc99) 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; 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 extern "C" */ @@ -101,8 +101,8 @@ struct GTY (()) cp_lexer { vec GTY ((skip)) saved_tokens; /* Saved pieces of end token we replaced with the eof token. */ + enum rid saved_keyword : 16; enum cpp_ttype saved_type : 8; - enum rid saved_keyword : 8; /* The next lexer in a linked list of lexers. */ struct cp_lexer *next; diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index fcdaf082b09..b93899cd364 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -988,7 +988,7 @@ struct GTY(()) cpp_hashnode { unsigned int directive_index : 7; /* If is_directive, then index into directive table. Otherwise, a NODE_OPERATOR. */ - unsigned int rid_code : 8; /* Rid code - for front ends. */ + unsigned int rid_code : 16; /* Rid code - for front ends. */ unsigned int flags : 9; /* CPP flags. */ ENUM_BITFIELD(node_type) type : 2; /* CPP node type. */