From patchwork Thu Aug 1 14:56:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 94989 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 9E85E3861003 for ; Thu, 1 Aug 2024 15:15:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id 16A38385DDFD for ; Thu, 1 Aug 2024 14:59:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 16A38385DDFD 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 16A38385DDFD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::132 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524378; cv=none; b=TePerNUaSo941Tz7RMTg4583Aux3DTpXH+SkoymIuoLCjcdMMVJGIzbBBMZF5EWtFl0ryklMAlFxsMwydLr0mlCLvEdo/fG56RKSfNKoWcG9pbX74z7kE5OpExk1E+qaX5U/pBpKQEhVg2+OOVvZZZsrEgehQcAW1PW6NZLvpxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524378; c=relaxed/simple; bh=tkDmo6XJ3lD1jFDvvSsBCGcDjSf0bK4M8wEhKf7DSfw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=j8OlXE1vn7m7+uA92+4xQeuuh54ggwtcFnOC3ULnlhq9lwnVGTihx3YNGkC5p4X5qXlhRqnyC53viV7J6KGf1XmvZBKla3SZ+JZrbbGftgpUuY+20s+6pyy8q4G8hcMuE17gR7EDJWDbiwuW0YKtd9D0bruLWmEULCoPWwMHQKM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-530ad969360so3385565e87.0 for ; Thu, 01 Aug 2024 07:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1722524348; x=1723129148; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3yERf4637HtxipdQMRKMW3mxUMYNiJv6XCkQb05nOJE=; b=Xnmmj4RDXTOimwetsURQxVHnOhdshQO+nrkWi8j6Vm4gGaa4iRcbHHad2+wJwLC4NR 24ej4udcJOfWYsA8dTxH1rRVD154VSar/Wwqri8Aofn10dCL4SKo1taE9L4GUckYwhh9 cUlM+ROr7QbgZWD2FuHc2aUJmJEkQkREWf1x6G7jU8e6OCO9XwGj33McEzdgHOzLUE6p WnGJ6FEOONVPFUBiypQ5nxKgxg+hqWNadsh8CM+oNfFNjrsUaX1TR6cSPBIh6whjFckj 7mRbdoH6jLMFrEmqozTDraVwZpdCgvmbXUzqWFbVI8gCBmw0WWdZBoev4PHARugALmQ5 RQ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722524348; x=1723129148; h=content-transfer-encoding:mime-version: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=3yERf4637HtxipdQMRKMW3mxUMYNiJv6XCkQb05nOJE=; b=oLBAowYarnX0g9W0Y7qTk2X3fZ8ssHVu+XRBL+YF1Q3RrbyOkBa+lfrHGVcpHCRssc j2rtRpoPG7JO7yoBcm2heVvkYJn/7nKWJJkVu8/yxXq+ArC+PIga0GDkgX0l2yDeqFy0 XtJBLGr2HOi9VG9a9v9eFkA8Cfrn1CrlQofzJ6Xy9IUU1lbrqw6bciGNpcMSHzo3cEQi bDiosO7Xs7AtZXEp4KlpmxMuTExZ3WK7xAluYMSDVG6rFKmdLfPyzJt00QvnRRdlyy2V Ev5cClei4c1mtNRiBx5ieJEcOaelk0KDcs+wXl5FEO4zTv7s6M8vY5lGVBH/mKxNbFP6 VC/Q== X-Gm-Message-State: AOJu0YzkSux1V1UKSaABHtEIAWgktt+/LRGg0BQjI9YpXzASFZlt8B2h AVqtL/7ZD70EgJ9gzvTzo1fkEbfjIdpAIeU5DmQL5N4dgHDMw7bFvEtMwGujFtwUD9ZxhETEkuA trISH X-Google-Smtp-Source: AGHT+IE3SXAnKbg9iXEJOVxvjtCQcIJNjM7uq1ubXKzPn7LffzwV+Q5izLUExbOh93CuPbJ00br2AA== X-Received: by 2002:ac2:4c48:0:b0:52e:74f5:d13 with SMTP id 2adb3069b0e04-530bb3a2256mr90072e87.30.1722524348168; Thu, 01 Aug 2024 07:59:08 -0700 (PDT) Received: from platypus.lan ([2a04:cec2:9:dc84:3622:6733:ff49:ee91]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63590592sm10252456a12.25.2024.08.01.07.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:59:07 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [PATCH 047/125] gccrs: format-args: Add base for expanding FormatArgs nodes Date: Thu, 1 Aug 2024 16:56:43 +0200 Message-ID: <20240801145809.366388-49-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801145809.366388-2-arthur.cohen@embecosm.com> References: <20240801145809.366388-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, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org gcc/rust/ChangeLog: * Make-lang.in: Add new object. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Remove calls to FormatArgsLowering. * expand/rust-expand-format-args.cc: New file. * expand/rust-expand-format-args.h: New file. --- gcc/rust/Make-lang.in | 1 + gcc/rust/expand/rust-expand-format-args.cc | 43 ++++++++++++++++++++++ gcc/rust/expand/rust-expand-format-args.h | 32 ++++++++++++++++ gcc/rust/hir/rust-ast-lower-expr.cc | 4 -- 4 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 gcc/rust/expand/rust-expand-format-args.cc create mode 100644 gcc/rust/expand/rust-expand-format-args.h diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in index f166b02340d..cbb9da0fe43 100644 --- a/gcc/rust/Make-lang.in +++ b/gcc/rust/Make-lang.in @@ -205,6 +205,7 @@ GRS_OBJS = \ rust/rust-unicode.o \ rust/rust-punycode.o \ rust/rust-lang-item.o \ + rust/rust-expand-format-args.o \ $(END) # removed object files from here diff --git a/gcc/rust/expand/rust-expand-format-args.cc b/gcc/rust/expand/rust-expand-format-args.cc new file mode 100644 index 00000000000..52249cb17e3 --- /dev/null +++ b/gcc/rust/expand/rust-expand-format-args.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2024 Free Software Foundation, Inc. + +// This file is part of GCC. + +// GCC is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3, or (at your option) any later +// version. + +// GCC is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. + +// You should have received a copy of the GNU General Public License +// along with GCC; see the file COPYING3. If not see +// . + +#include "rust-expand-format-args.h" +#include "rust-builtin-ast-nodes.h" + +namespace Rust { + +tl::optional +expand_format_args (AST::FormatArgs &fmt) +{ + for (const auto &node : fmt.get_template ().get_pieces ()) + { + switch (node.tag) + { + case Fmt::Piece::Tag::String: + // rust_debug ("[ARTHUR]: %s", node.string._0.c_str ()); + + case Fmt::Piece::Tag::NextArgument: + rust_debug ("[ARTHUR]: NextArgument"); + break; + } + } + + return tl::nullopt; +} + +} // namespace Rust diff --git a/gcc/rust/expand/rust-expand-format-args.h b/gcc/rust/expand/rust-expand-format-args.h new file mode 100644 index 00000000000..1481f3605ed --- /dev/null +++ b/gcc/rust/expand/rust-expand-format-args.h @@ -0,0 +1,32 @@ +// Copyright (C) 2024 Free Software Foundation, Inc. + +// This file is part of GCC. + +// GCC is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation; either version 3, or (at your option) any later +// version. + +// GCC is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. + +// You should have received a copy of the GNU General Public License +// along with GCC; see the file COPYING3. If not see +// . + +#ifndef RUST_EXPAND_FORMAT_ARGS_H +#define RUST_EXPAND_FORMAT_ARGS_H + +#include "optional.h" +#include "rust-ast-fragment.h" + +namespace Rust { + +tl::optional +expand_format_args (AST::FormatArgs &fmt); + +} // namespace Rust + +#endif //! RUST_EXPAND_FORMAT_ARGS_H diff --git a/gcc/rust/hir/rust-ast-lower-expr.cc b/gcc/rust/hir/rust-ast-lower-expr.cc index 6944db9b9cc..c414643bb91 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.cc +++ b/gcc/rust/hir/rust-ast-lower-expr.cc @@ -19,7 +19,6 @@ #include "rust-ast-lower-expr.h" #include "rust-ast-lower-base.h" #include "rust-ast-lower-block.h" -#include "rust-ast-lower-format-args.h" #include "rust-ast-lower-struct-field-expr.h" #include "rust-ast-lower-pattern.h" #include "rust-ast-lower-type.h" @@ -824,9 +823,6 @@ ASTLoweringExpr::visit (AST::ClosureExprInnerTyped &expr) void ASTLoweringExpr::visit (AST::FormatArgs &fmt) { - // Lowering FormatArgs is complex, and this file is already very long - translated = FormatArgsLowering ().go (fmt); - rust_sorry_at (fmt.get_locus (), "FormatArgs lowering is not implemented yet"); }