From patchwork Wed Apr 5 14:04:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 79744 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp373354vqo; Wed, 5 Apr 2023 08:03:05 -0700 (PDT) X-Google-Smtp-Source: AKy350aZlF1sd6qRe9UXzbEjvPJ+Sb4PhfPQHd6jz0jyUW9BKwv2wMCrp1DnDEBa/znLWH9LLOIk X-Received: by 2002:aa7:d3d5:0:b0:4fb:fd22:29c0 with SMTP id o21-20020aa7d3d5000000b004fbfd2229c0mr1828056edr.26.1680706985570; Wed, 05 Apr 2023 08:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680706985; cv=none; d=google.com; s=arc-20160816; b=i1wSBv93eDj/7e1FaKuTERYCtLyHtCKi9Aw3cAf4nWewP6OIXV0pm/eOpWAgHJCDTU sq0FW+EYU1Rh29QEGC93+YP2XbZlRYoQZKaxl088DFZOu1aIJK+KNZwUax3nAwjyh1eO Hwaz4jIZK4+n6tqeQb7U0uKn/4EiUNToIsMuivxpwO2gd7RbvsGN+rMbKi9oRpaQGBDC 1FoPIX1cEhl7D19s4TdG49V8+Wh5P/T1Fpg8FWvFQU9KsaJPPk0AKAf6NCJSnKbuagRe CwNWdbZXzuy9zBqCbc+5bzCgf63YpBf2RBLFckEtTrWiTOhSqhmdH2qGu2aoyaue4HFv pcHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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:dmarc-filter :delivered-to; bh=AH5VbKw/CfE3qN4pWx4GtpMg3pQzXtQuwepFbngSu3w=; b=Lo30fIDUvNbNU0m16/o/08pESusftr/8TAbgWpY0nVMUTQkBWnb1oUdX6kR/Yu9yd+ 7AVYkc93wMORmleh//C5iP5CgtkJg7mkuD7ntMh6+HDkysLKKtj7DFXsyGdEYX7cF9rZ vZRlPl6XMfKq3CMaOGgJyciGDjglakC+HNBS7BBJnTMXSuZATWBpSPR2RWmKm4h2ESCc Mbb+K5Ru2leMgIfUi6m4GUq79KS6vUpJATAlcikgi7rIGGVws7aav84xHzUV0A8ZqtZQ nnhcjZNh1omO9fXpcAJQ1eKIJLtEEcLkn8iW5JIdsX+60ZCj4iYYVfWjg+0lAhssILac 6tGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=cxmgVpUW; 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" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id zb20-20020a17090687d400b0093b62d1f8e0si3357261ejb.271.2023.04.05.08.03.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 08:03:05 -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=@embecosm.com header.s=google header.b=cxmgVpUW; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6CA4038E6136 for ; Wed, 5 Apr 2023 14:23:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id F2CF03856DCA for ; Wed, 5 Apr 2023 14:06:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2CF03856DCA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x331.google.com with SMTP id n10-20020a05600c4f8a00b003ee93d2c914so23483535wmq.2 for ; Wed, 05 Apr 2023 07:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1680703588; 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=AH5VbKw/CfE3qN4pWx4GtpMg3pQzXtQuwepFbngSu3w=; b=cxmgVpUW9qLA7j6EN+FiMKkuKKgpBTmbIQ0JfSiQ2bimwR/kIJiGXtiYpHHTB7dSCI 1/ysVMJszvL3jl+cX8fskdkJ6gha2coLmVaVUR/19bmfeKozQJ78UGiVLq/WoH95Whrd 0tLgL+rq32NbZSWrZCv6mFJAjMLiW4uMalvQuF70t0Nm0b4FLwNAFJQ45zpwpLoZW5hz 59Y2Gqsd0StQbpdZzSFTiJk43KaZFeKKExv36gHF6gxRytQv+0ZW84rEu5MuMqHkmry4 Odtb1xsHylT3w3XZhSYvNOJ1CzzPxtXnubwLfg3+Zs1IwLeVuoqMFHh0xrB2ZAS9zg13 l2CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680703588; 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=AH5VbKw/CfE3qN4pWx4GtpMg3pQzXtQuwepFbngSu3w=; b=N0N6sV5qPQCzypl9zpSj+SEc1goUfhKIEUAQABN2b3sK9ogmzr6IfDgZhpcxiinduG VjrjWwcQMeQePt1gPBMRY4nf+0KQ+IKb3osJhY1f9XaMaEFbVtDpNHthHpHMWRovIZxG HCIKOiggUp/94QpBc9YmgTKpG2KSuofWWddgWQdtT3i5kc9KBru3mC6Tho7/q73MmDrb CWZlY+xd6CUyhKVMbvEjPN/6FNyPlW9EuOBLfPhBvINu/sVniCUxfd4Pwj9UhD+oirfT uuhvypR1nhb9W4ryaZ9iaQs8DshR/YawCsmzG9NDgAzIT+yA0gmGL0eixSO7hyKR1GGy 2o0w== X-Gm-Message-State: AAQBX9cc2jrUkTwXrCw7QHX82C5ZtlzSwwCf+eUZ19lxAVQ8XKVd7xQk dDY4G9HmZ1+CqYnZKXfOimDBzGMdZhRULiRB9g== X-Received: by 2002:a7b:c455:0:b0:3ee:1afc:c15 with SMTP id l21-20020a7bc455000000b003ee1afc0c15mr4495247wmi.33.1680703588492; Wed, 05 Apr 2023 07:06:28 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id ay8-20020a05600c1e0800b003edddae1068sm2330150wmb.9.2023.04.05.07.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 07:06:28 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, M V V S Manoj Kumar Subject: [committed 86/88] gccrs: Added AST Node AST::InlineAsm Date: Wed, 5 Apr 2023 16:04:10 +0200 Message-Id: <20230405140411.3016563-87-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230405140411.3016563-1-arthur.cohen@embecosm.com> References: <20230405140411.3016563-1-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.5 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 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.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762349008509011992?= X-GMAIL-MSGID: =?utf-8?q?1762349008509011992?= From: M V V S Manoj Kumar Addresses #1567 Created a AST node InlineAsm similar to the one found in rustc. As there is no Symbol struct/class in gccrs I have made every instance of Symbol a string. gcc/rust/ChangeLog: * ast/rust-ast-full-decls.h (class InlineAsm):Added class declaration. * ast/rust-expr.h (class InlineAsm):Added class definition. Signed-off-by: M V V S Manoj Kumar --- gcc/rust/ast/rust-ast-full-decls.h | 1 + gcc/rust/ast/rust-expr.h | 138 +++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) diff --git a/gcc/rust/ast/rust-ast-full-decls.h b/gcc/rust/ast/rust-ast-full-decls.h index 9d7b00ac5a2..64341d32641 100644 --- a/gcc/rust/ast/rust-ast-full-decls.h +++ b/gcc/rust/ast/rust-ast-full-decls.h @@ -149,6 +149,7 @@ struct MatchCase; class MatchExpr; class AwaitExpr; class AsyncBlockExpr; +class InlineAsm; // rust-stmt.h class EmptyStmt; diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 3ed1885d5af..f5461848009 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -4634,6 +4634,144 @@ protected: return new AsyncBlockExpr (*this); } }; + +// Inline Assembly Node +class InlineAsm : public ExprWithoutBlock +{ + // Inline-assembly specific options + enum InlineAsmOptions + { + PURE = 1 << 0, + NOMEM = 1 << 1, + READONLY = 1 << 2, + PRESERVES_FLAGS = 1 << 3, + NORETURN = 1 << 4, + NOSTACK = 1 << 5, + ATT_SYNTAX = 1 << 6, + RAW = 1 << 7, + MAY_UNWIND = 1 << 8, + }; + + struct AnonConst + { + NodeId id; + std::unique_ptr value; + }; + + struct InlineAsmRegOrRegClass + { + enum Type + { + Reg, + RegClass, + }; + + struct Reg + { + std::string Symbol; + }; + + struct RegClass + { + std::string Symbol; + }; + + Identifier name; + Location locus; + }; + + struct InlineAsmOperand + { + enum RegisterType + { + In, + Out, + InOut, + SplitInOut, + Const, + Sym, + }; + + struct In + { + InlineAsmRegOrRegClass reg; + std::unique_ptr expr; + }; + + struct Out + { + InlineAsmRegOrRegClass reg; + bool late; + std::unique_ptr expr; // can be null + }; + + struct InOut + { + InlineAsmRegOrRegClass reg; + bool late; + std::unique_ptr expr; // this can't be null + }; + + struct SplitInOut + { + InlineAsmRegOrRegClass reg; + bool late; + std::unique_ptr in_expr; + std::unique_ptr out_expr; // could be null + }; + + struct Const + { + AnonConst anon_const; + }; + + struct Sym + { + std::unique_ptr sym; + }; + Location locus; + }; + + struct InlineAsmPlaceHolder + { + size_t operand_idx; + char modifier; // can be null + Location locus; + }; + + struct InlineAsmTemplatePiece + { + bool is_placeholder; + union + { + std::string string; + InlineAsmPlaceHolder placeholder; + }; + }; + + struct TupleClobber + { + // as gccrs still doesen't contain a symbol class I have put them as strings + std::string symbol; + Location loc; + }; + + struct TupleTemplateStr + { + // as gccrs still doesen't contain a symbol class I have put them as strings + std::string symbol; + std::string optional_symbol; + Location loc; + }; + +public: + std::vector template_; + std::vector template_strs; + std::vector operands; + TupleClobber clobber_abi; + InlineAsmOptions options; + std::vector line_spans; +}; } // namespace AST } // namespace Rust