From patchwork Tue Jan 30 12:06:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 194052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1178478dyb; Tue, 30 Jan 2024 04:19:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFK16BgOCKLflCkCudULJ9YfI+xD0y1956qu0Hl0P77M09K6DuSdgBzkZmdevv4vq6PuDyj X-Received: by 2002:a0c:ea24:0:b0:68c:3be6:8ef9 with SMTP id t4-20020a0cea24000000b0068c3be68ef9mr6436136qvp.43.1706617172405; Tue, 30 Jan 2024 04:19:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706617172; cv=pass; d=google.com; s=arc-20160816; b=yy9g41EwD1FgIlA0kUe+Anp8WF7Sgod1v/RPg1U1dAwUO0B4ZAZryD/OkFKjNkpmmq dW/LvAIiKHI+b1jDj3gi0lO2qJUkszTZyPkAxyONaEq1/ebup2Q95VzzPbdYoGJt923W 7IgfX6XH9ySN4OZVGgEV0kI9FuJ9lSsNpGKn5+clrJyu1QV9WJAtnb9FEmguzNVt6k0s DQuI7y6fTq4558iPdzeYJla+c1OoZU7oh86wBDnZ4INKIc/Acoz9CzLynDpiaI8Fh6sx EvCgwCO93/FqD3E6d+2FmcdkelmGIIHgZOZ7gRcLnL42Vw5TowexxQXi8bwGdd8J5n8N SofQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to: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 :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=AAA+tUrpjHaW4zs1uyJOfNzO47oHzJEHDWM2+KLxQRQ=; fh=6KiXNvQww/MsyVplklPLl//mUuD+DtDm73nSHh4O4+g=; b=kYT24yqPXZ/74vVvOYLcMAen6B7/UF3d36GdOiCphYPDIRZCkRy8bs+1fab1TiCTkw i3M5ddenEyk+4ok9Qhmnhu55Pkadaqdi00sQirMpCRPpLxAGL9lYjOQCgHZyGbW5u9nh rcKCeZhgIcI5mOlYcyW2XhTQMajfg/ktFdDUNKTHjY5bF1+AQbuij79Mygqy+A5wiT82 j9eeY4odamDSEyKyqwLWc+8WtA5rHFj5XM/xi9D/VP2m6RusuT4cSbpcvj8t5rwFbwgq D2d9WQ9sF89VTyRh0puMenaJxVouVuqS8pTJk0gBcDHdwwnTZ8PEctT98DIFM7u3hqAb VKPw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=PHEB+hra; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id pt6-20020a056214048600b0068c3a003bbdsi8065324qvb.493.2024.01.30.04.19.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:19:32 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=PHEB+hra; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EEF0338582A6 for ; Tue, 30 Jan 2024 12:19:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 9DF423858034 for ; Tue, 30 Jan 2024 12:11:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9DF423858034 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9DF423858034 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::229 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616664; cv=none; b=rWxilQ4iYBf+7NcYf2PY5ALou6ry0JOKODfc4ddlz+esV2PAsR3txcq3EncecjW5RIRP5gnIvqy3I2BfzeVJA4YUYwaeEiVN+SH4xSAFZ5UCl+hl2BQdavBR0nq9Icbc54twDNMBp1tw/hQIB+/LbzlgZP5oSKmISMrPTJcOIg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616664; c=relaxed/simple; bh=u0LufJgOETfsbbkuJgKzJVFxRbyQmbFFz0nirPTbPoc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=YO5j3+UZtn1ckitZg5dx/dUDz0EhT7kjHCYOKI84WoycfEaiN2PxWe9721eg9kYld2Yx2Xu1xrToxtVsYiYq56qT0OqNQkn5nXgFxecJpd1bh6YjHTMWt+NwP3IRIascnx1fbmEvjT/82TMSiSWjWsI4GVsgBheoespaUwX15Qg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2cf206e4d56so41758001fa.3 for ; Tue, 30 Jan 2024 04:11:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616660; x=1707221460; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=AAA+tUrpjHaW4zs1uyJOfNzO47oHzJEHDWM2+KLxQRQ=; b=PHEB+hraSZXqGyLlHU+2CoCZO1kf9vs1F2/CclLpsnjpxlkIqkFHz4FZAqtvNbNri0 xio1FqubPBPBPmCuLel34i9qNVZbEIVbbquefBSTwXy3O76D82uFHKY6LuX5MDprvUCb kvSRUIakT8xQC8t6m4k7Nt8KPUCSRR9cYCn7eOp3IWDk3vQKbWMgHGml+5z+kVL8/yIA taCh92V2cABGjP++2lcPSf0Go3HR7eG1PqcO2WEwis5PDQxFHYW9Bs+oLgHo8yJSnekU +szQTsgLNehSdrtz+MQjxKQdMayKNXjV8F023tour+Qjdn/LP+wv2JZ1J32fo+72NaNs QjjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616660; x=1707221460; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AAA+tUrpjHaW4zs1uyJOfNzO47oHzJEHDWM2+KLxQRQ=; b=dANVzAmyVuL8q/gJ/IW8bDGvdXhYuX47+7PO+Mk55aAkg6m5Ibu4o1vWlBv0PqwX95 fQ7AKTvB42Cy1xJ7/bvgJXDDglRU5sxboVRO7/h5do3y4bYOSozyvWcUL5qDSskYzGAq 7FgJ9nLPeaOR1tEupROxbCW04vB2IiW1jxLylwNeKSRBWwrx2GxjTXOdJ4PQXR+UIOau k3pIBv6uTukdWZjG20nWieWgV2mrONWG6tbr980xlxkjybzimGSoyUWp1ZmJo9hvISQQ N74gn8uYpziBV47AN8vo7WMRs+GZDI+xPQ2hYYIKCWCCnShRbzalBuj+3LybFPDHrUuO dtiA== X-Gm-Message-State: AOJu0Yyc/FVhQH0Ox3TPUx7nT/VtwOcl+43bBqpjoIi10EcsoI1m78kZ XM8IZFnohqvSKmoMq1HDweVpQnTLUjEAMvl7mvUKmAoxmo0KgRP+YwNE0xwn80Fgctx2o12id78 /VA== X-Received: by 2002:a2e:b8c4:0:b0:2cd:3b6:b3d7 with SMTP id s4-20020a2eb8c4000000b002cd03b6b3d7mr6308444ljp.34.1706616659853; Tue, 30 Jan 2024 04:10:59 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id f9-20020a056000036900b00339307d9d31sm10569894wrf.112.2024.01.30.04.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:10:58 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [COMMITTED 013/101] gccrs: foreverstack: Add `to_rib` method Date: Tue, 30 Jan 2024 13:06:29 +0100 Message-ID: <20240130121026.807464-16-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240130121026.807464-2-arthur.cohen@embecosm.com> References: <20240130121026.807464-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789517807858187274 X-GMAIL-MSGID: 1789517807858187274 From: Arthur Cohen gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: New method. * resolve/rust-forever-stack.hxx: Likewise. --- gcc/rust/resolve/rust-forever-stack.h | 2 ++ gcc/rust/resolve/rust-forever-stack.hxx | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gcc/rust/resolve/rust-forever-stack.h b/gcc/rust/resolve/rust-forever-stack.h index 37277ddb3ad..a540e682e5b 100644 --- a/gcc/rust/resolve/rust-forever-stack.h +++ b/gcc/rust/resolve/rust-forever-stack.h @@ -585,6 +585,8 @@ private: // FIXME: Documentation tl::optional> dfs (Node &starting_point, NodeId to_find); + // FIXME: Documentation + tl::optional dfs_rib (Node &starting_point, NodeId to_find); }; } // namespace Resolver2_0 diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index 4e06da235bf..65796172b08 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -532,11 +532,29 @@ ForeverStack::to_canonical_path (NodeId id) template tl::optional -ForeverStack::to_rib (NodeId rib_id) +ForeverStack::dfs_rib (ForeverStack::Node &starting_point, NodeId to_find) { + if (starting_point.id == to_find) + return starting_point.rib; + + for (auto &child : starting_point.children) + { + auto candidate = dfs_rib (child.second, to_find); + + if (candidate.has_value ()) + return candidate; + } + return tl::nullopt; } +template +tl::optional +ForeverStack::to_rib (NodeId rib_id) +{ + return dfs_rib (root, rib_id); +} + template void ForeverStack::stream_rib (std::stringstream &stream, const Rib &rib,