diff options
author | jjasmine <tanghocle456@gmail.com> | 2024-06-10 14:04:11 -0700 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:46 +0100 |
commit | 83465864dbddcebca788df417783eb4e074626f8 (patch) | |
tree | 86d1b56956e611a4775f2d8e85022ab07f2ae325 /gcc/rust/ast/rust-expr.h | |
parent | e0eb48c3a91e3920785da3f8f96ee8cd71ee55c3 (diff) | |
download | gcc-83465864dbddcebca788df417783eb4e074626f8.zip gcc-83465864dbddcebca788df417783eb4e074626f8.tar.gz gcc-83465864dbddcebca788df417783eb4e074626f8.tar.bz2 |
gccrs: Refactoring and supporting more parse_reg_operand
gcc/rust/ChangeLog:
* ast/rust-expr.h (struct InlineAsmOperand):
Refactoring and supporting more parse_reg_operand
* expand/rust-macro-builtins-asm.cc (parse_reg_operand):
Likewise.
(rust_debug): Likewise.
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 75 |
1 files changed, 71 insertions, 4 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 5f60ec7..30146b2 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -4781,10 +4781,15 @@ struct InlineAsmOperand struct In { - InlineAsmRegOrRegClass reg; + tl::optional<InlineAsmRegOrRegClass> reg; std::unique_ptr<Expr> expr; In () {} + In (tl::optional<struct InlineAsmRegOrRegClass> ®, + std::unique_ptr<Expr> expr) + : reg (reg), expr (std::move (expr)) + {} + In (const struct In &other) { reg = other.reg; @@ -4804,11 +4809,17 @@ struct InlineAsmOperand struct Out { - InlineAsmRegOrRegClass reg; + tl::optional<InlineAsmRegOrRegClass> reg; bool late; std::unique_ptr<Expr> expr; // can be null Out () {} + + Out (tl::optional<struct InlineAsmRegOrRegClass> ®, bool late, + std::unique_ptr<Expr> expr) + : reg (reg), late (late), expr (std::move (expr)) + {} + Out (const struct Out &other) { reg = other.reg; @@ -4829,11 +4840,16 @@ struct InlineAsmOperand struct InOut { - InlineAsmRegOrRegClass reg; + tl::optional<InlineAsmRegOrRegClass> reg; bool late; std::unique_ptr<Expr> expr; // this can't be null InOut () {} + InOut (tl::optional<struct InlineAsmRegOrRegClass> ®, bool late, + std::unique_ptr<Expr> expr) + : reg (reg), late (late), expr (std::move (expr)) + {} + InOut (const struct InOut &other) { reg = other.reg; @@ -4855,12 +4871,19 @@ struct InlineAsmOperand struct SplitInOut { - InlineAsmRegOrRegClass reg; + tl::optional<InlineAsmRegOrRegClass> reg; bool late; std::unique_ptr<Expr> in_expr; std::unique_ptr<Expr> out_expr; // could be null SplitInOut () {} + + SplitInOut (tl::optional<struct InlineAsmRegOrRegClass> ®, bool late, + std::unique_ptr<Expr> in_expr, std::unique_ptr<Expr> out_expr) + : reg (reg), late (late), in_expr (std::move (in_expr)), + out_expr (std::move (out_expr)) + {} + SplitInOut (const struct SplitInOut &other) { reg = other.reg; @@ -4925,6 +4948,50 @@ struct InlineAsmOperand split_in_out (other.split_in_out), cnst (other.cnst), sym (other.sym) {} + void set_in (const tl::optional<struct In> ®) + { + this->register_type = In; + + if (reg.has_value ()) + this->in = reg.value (); + } + + void set_out (const tl::optional<struct Out> ®) + { + this->register_type = Out; + + if (reg.has_value ()) + this->out = reg.value (); + } + + void set_in_out (const tl::optional<struct InOut> ®) + { + this->register_type = InOut; + if (reg.has_value ()) + this->in_out = reg.value (); + } + + void set_split_in_out (const tl::optional<struct SplitInOut> ®) + { + this->register_type = SplitInOut; + if (reg.has_value ()) + this->split_in_out = reg.value (); + } + + void set_cnst (const tl::optional<struct Const> ®) + { + this->register_type = Const; + if (reg.has_value ()) + this->cnst = reg.value (); + } + + void set_sym (const tl::optional<struct Sym> ®) + { + this->register_type = Sym; + if (reg.has_value ()) + this->sym = reg.value (); + } + location_t locus; }; |