diff options
author | 0xn4utilus <gyanendrabanjare8@gmail.com> | 2025-05-07 22:21:10 +0530 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2025-05-08 15:38:58 +0000 |
commit | dd3de3f0e5516573179b2ed412fa87e0c8bd246a (patch) | |
tree | 0c485b9f54cbf207bcac5f9fc241b611d806877d /gcc/rust/ast/rust-expr.h | |
parent | 339415a5a865649972b255cc697691d493453e41 (diff) | |
download | gcc-dd3de3f0e5516573179b2ed412fa87e0c8bd246a.zip gcc-dd3de3f0e5516573179b2ed412fa87e0c8bd246a.tar.gz gcc-dd3de3f0e5516573179b2ed412fa87e0c8bd246a.tar.bz2 |
ast: collector: visit InlineAsm node during ast dump
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Implement for InlineAsm.
* ast/rust-ast-full-decls.h (enum class): Move InlineAsmOption enum inside InlineAsm.
* ast/rust-expr.h (enum class): Likewise.
(class InlineAsm): Likewise.
* expand/rust-macro-builtins-asm.cc (check_and_set): Likewise.
(parse_options): Likewise.
* expand/rust-macro-builtins-asm.h (check_and_set): Likewise.
* hir/tree/rust-hir-expr.cc (InlineAsm::InlineAsm): Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index fdb6360..9ecca22 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -4822,20 +4822,6 @@ protected: } }; -// Inline-assembly specific options -enum class InlineAsmOption -{ - 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; @@ -5288,6 +5274,20 @@ struct TupleTemplateStr // Inline Assembly Node class InlineAsm : public ExprWithoutBlock { +public: + enum class Option + { + 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, + }; + private: location_t locus; // TODO: Not sure how outer_attrs plays with InlineAsm, I put it here in order @@ -5311,7 +5311,7 @@ public: std::map<std::string, int> named_args; std::set<int> reg_args; std::vector<TupleClobber> clobber_abi; - std::set<InlineAsmOption> options; + std::set<InlineAsm::Option> options; std::vector<location_t> line_spans; @@ -5342,7 +5342,7 @@ public: std::vector<TupleClobber> get_clobber_abi () { return clobber_abi; } - std::set<InlineAsmOption> get_options () { return options; } + std::set<InlineAsm::Option> get_options () { return options; } InlineAsm *clone_expr_without_block_impl () const override { @@ -5350,6 +5350,33 @@ public: } Expr::Kind get_expr_kind () const override { return Expr::Kind::InlineAsm; } + + static std::string option_to_string (Option option) + { + switch (option) + { + case Option::PURE: + return "pure"; + case Option::NOMEM: + return "nomem"; + case Option::READONLY: + return "readonly"; + case Option::PRESERVES_FLAGS: + return "preserves_flags"; + case Option::NORETURN: + return "noreturn"; + case Option::NOSTACK: + return "nostack"; + case Option::ATT_SYNTAX: + return "att_syntax"; + case Option::RAW: + return "raw"; + case Option::MAY_UNWIND: + return "may_unwind"; + default: + rust_unreachable (); + } + } }; class LlvmInlineAsm : public ExprWithoutBlock |