From 83465864dbddcebca788df417783eb4e074626f8 Mon Sep 17 00:00:00 2001 From: jjasmine Date: Mon, 10 Jun 2024 14:04:11 -0700 Subject: 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. --- gcc/rust/ast/rust-expr.h | 75 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 4 deletions(-) (limited to 'gcc/rust/ast/rust-expr.h') 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 reg; std::unique_ptr expr; In () {} + In (tl::optional ®, + std::unique_ptr 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 reg; bool late; std::unique_ptr expr; // can be null Out () {} + + Out (tl::optional ®, bool late, + std::unique_ptr 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 reg; bool late; std::unique_ptr expr; // this can't be null InOut () {} + InOut (tl::optional ®, bool late, + std::unique_ptr 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 reg; bool late; std::unique_ptr in_expr; std::unique_ptr out_expr; // could be null SplitInOut () {} + + SplitInOut (tl::optional ®, bool late, + std::unique_ptr in_expr, std::unique_ptr 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 ®) + { + this->register_type = In; + + if (reg.has_value ()) + this->in = reg.value (); + } + + void set_out (const tl::optional ®) + { + this->register_type = Out; + + if (reg.has_value ()) + this->out = reg.value (); + } + + void set_in_out (const tl::optional ®) + { + this->register_type = InOut; + if (reg.has_value ()) + this->in_out = reg.value (); + } + + void set_split_in_out (const tl::optional ®) + { + this->register_type = SplitInOut; + if (reg.has_value ()) + this->split_in_out = reg.value (); + } + + void set_cnst (const tl::optional ®) + { + this->register_type = Const; + if (reg.has_value ()) + this->cnst = reg.value (); + } + + void set_sym (const tl::optional ®) + { + this->register_type = Sym; + if (reg.has_value ()) + this->sym = reg.value (); + } + location_t locus; }; -- cgit v1.1