From patchwork Tue Aug 6 21:27:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andrew Pinski (QUIC)" X-Patchwork-Id: 95403 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A4D73858C33 for ; Tue, 6 Aug 2024 21:28:05 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by sourceware.org (Postfix) with ESMTPS id 8F8CC3858402 for ; Tue, 6 Aug 2024 21:27:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F8CC3858402 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8F8CC3858402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722979650; cv=none; b=PjUOsois8yuxT7CMbTcPX+hdFaVuJH/lcvKcXTX0UoR6j5B4yatBoKGxRMtbRAYGdmwAbLlTxW5vIl4apjL8uWb049QkUUl/gsTd7f7Ji9WITEeK3JLSaf7L7WdUyz0/YiilYKInc6nSeLxmWtCDnUomqqAAu2WOX561H+K8NMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722979650; c=relaxed/simple; bh=5NajqrTaOsuNcXV45YIhNZZD1ai2WwBGF9HwK8zm4Ag=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Jvela+aw8N9lKuEtwWogiaJ32OZhy96UQfBoQ2Sq4d114hbsRKThLmsMSkIU9QL/OiROo53qRcuBOBJ4E+xyYx0jZ5tPVAWyqROkOo3ipEz5c6mxoNKETe5ZipAaZXBYxFTeABYlb4yEc/tx9yGrzqVGtelrVySYcGE3TN6KfZY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 476H6WRW023013 for ; Tue, 6 Aug 2024 21:27:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= vzI0k1mSUi3a/+ucf2tO71v8PZ+ZqcV82QAWkt7L8+s=; b=Ls15wH+XWH0JhhWo Y9qjpcCTgBcYvLEgq1jMcdSIRYAKEmi0EoGbdjbpnuMhfnzr7angr1xlRDij27QK 5KQ8KodqzitnNy6QR6FOw8VVrE3QRQlxFQSyNsyTIrfJvHgr5It/8DSdu1SZrQeR +PWtT0+BOnFhIpz05evJvrjNzkiMIlPBawv0TV9ofqy08HQ03CWiHpISToTDSi8V Z+s5gYdQTfIc+4olkIu9VhS454kjXFVgi97BMkl1qjrllqE/s28Yyk7WexjKghRT BpED1/YshdeojZrpubf5hBSqUjTFxBz/A7YpUcSJd2KJfwKcsrH4S+ZIe029y+E3 Jy9srQ== Received: from nasanppmta05.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 40sbvggtc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 06 Aug 2024 21:27:27 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA05.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 476LRP3F008579 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 6 Aug 2024 21:27:25 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 6 Aug 2024 14:27:25 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH 3/5] ranger: constify range_op_table class Date: Tue, 6 Aug 2024 14:27:12 -0700 Message-ID: <20240806212714.308434-4-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240806212714.308434-1-quic_apinski@quicinc.com> References: <20240806212714.308434-1-quic_apinski@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Ob9Q1v0PCv-PSw05k_W0n5jfaQpdow-x X-Proofpoint-ORIG-GUID: Ob9Q1v0PCv-PSw05k_W0n5jfaQpdow-x X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-06_17,2024-08-06_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 mlxscore=0 mlxlogscore=966 adultscore=0 malwarescore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408060150 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, 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: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org While making range_op_table a singleton, I noticed that constification should be done to `operator[]` and that operator_table could be made as const as it does not get changed after it is initialized. Bootstrapped and tested on x86_64-linux. gcc/ChangeLog: * range-op.h (range_op_table): Make operator[] const. Have singleton return const reference. * range-op.cc (range_op_table::singleton): Update return type. (operator_table): Make const. Signed-off-by: Andrew Pinski --- gcc/range-op.cc | 4 ++-- gcc/range-op.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 56a014e99bc..9a889ea4bb4 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -75,7 +75,7 @@ operator_min op_min; operator_max op_max; // Instantaite a range operator table. -range_op_table &operator_table = range_op_table::singleton(); +const range_op_table &operator_table = range_op_table::singleton(); // Instantiate a default range operator for opcodes with no entry. range_operator default_operator; @@ -118,7 +118,7 @@ range_op_table::range_op_table () } // Returns the singleton instance of the table. -range_op_table &range_op_table::singleton() +const range_op_table &range_op_table::singleton() { static range_op_table single; return single; diff --git a/gcc/range-op.h b/gcc/range-op.h index e4e11f89624..f7ecc660fb9 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -391,12 +391,12 @@ extern void wi_set_zero_nonzero_bits (tree type, class range_op_table final { public: - inline range_operator *operator[] (unsigned code) + inline range_operator *operator[] (unsigned code) const { gcc_checking_assert (code < RANGE_OP_TABLE_SIZE); return m_range_tree[code]; } - static range_op_table &singleton(); + static const range_op_table &singleton(); private: inline void set (unsigned code, range_operator &op) {