From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id E943F3882AEB for ; Wed, 5 Apr 2023 14:06:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E943F3882AEB 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-x335.google.com with SMTP id m6-20020a05600c3b0600b003ee6e324b19so22074124wms.1 for ; Wed, 05 Apr 2023 07:06:28 -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=N1R/oui4wl2YMBVNOhKDBnxVofdGA2ijIWrcqGA6w2WPY05ZrtzwbaBFRdSwWjZpNc 4uBTrgL3ej4V/wjIIewVA5pZRAoQZpW80ACSimsWKBwg3pIe+ZCyiOB1/sx7e1KROQ31 h9muF6NNhnxex0Oh2ZyMiTlrcAOtlOKu0CH5ffZXFgZhALZ/Et/v6EptVAEzvJnHLYPy DOdIlq5lMvrivo9LVOVNOPTg4LKdL8OXyTwNKx+CwixYqtvUC3VUqwjBZLiU3+9faz5F riqmnVFGP2wh1VCEH2CJF9XUso1xeDOxsslP8UbG3bQfJ6qD4CfqCwopk/6BJOrtEG2z ppYQ== X-Gm-Message-State: AAQBX9cgFjYvHCpmA0vcK04+KmZ1gxVzDsIc3j0q/GruFMaLQvwaAaD0 bIV8VdbPWB+/gvBI4vIZ3dGz X-Google-Smtp-Source: AKy350blzVsBq4nINZIEkHW1Rk/W4ZPmXs0oeJHX/MMI8apSrYhL3OJON08E9Lr6QcoVaESK5uv6Sw== 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> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 -- 2.40.0