diff options
author | jjasmine <tanghocle456@gmail.com> | 2024-05-31 02:01:18 -0700 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:43 +0100 |
commit | f0c9a6e73d21eef5c5b3c6051f42e6e262eba1df (patch) | |
tree | 9b9408988c10232c6427b9c89f59bb5ffc44dbc1 /gcc/rust/ast | |
parent | 256bb62f995625ff32748e479b371c20082189ba (diff) | |
download | gcc-f0c9a6e73d21eef5c5b3c6051f42e6e262eba1df.zip gcc-f0c9a6e73d21eef5c5b3c6051f42e6e262eba1df.tar.gz gcc-f0c9a6e73d21eef5c5b3c6051f42e6e262eba1df.tar.bz2 |
gccrs: Refactoring for inline asm pr
gcc/rust/ChangeLog:
* ast/rust-expr.h (struct AnonConst):
major refactoring of inline asm, mostly concerns
naming convention, trinary conditionals, warnings,
adding rust_unreachables in not-yet supported errors.
(struct InlineAsmRegOrRegClass): Likewise.
(struct InlineAsmOperand): Likewise.
* expand/rust-macro-builtins-asm.cc (parse_clobber_abi): Likewise.
(parse_reg): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(check_and_set): Likewise.
(parse_options): Likewise.
(parse_format_string): Likewise.
(parse_asm_arg): Likewise.
(parse_asm): Likewise.
* expand/rust-macro-builtins-asm.h (parse_asm_arg): Likewise.
(check_identifier): Likewise.
(check_and_set): Likewise.
(parse_operand): Likewise.
(parse_reg_operand): Likewise.
(parse_options): Likewise.
(parse_reg): Likewise.
(parse_clobber_abi): Likewise.
* expand/rust-macro-builtins.cc (enum class): Likewise.
(inline_asm_maker): Likewise.
* checks/errors/borrowck/ffi-polonius/Cargo.lock: Removed. Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/inline_asm_faulty_clobber.rs: Likewise.
* rust/compile/inline_asm_faulty_clobber_1.rs: Likewise.
* rust/compile/inline_asm_faulty_clobber_2.rs: Likewise.
* rust/compile/inline_asm_illegal_options.rs: Likewise.
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 88 |
1 files changed, 41 insertions, 47 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 1284c73..ad742bf 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -6,7 +6,7 @@ #include "rust-path.h" #include "rust-macro.h" #include "rust-operators.h" -#include <memory> +#include "rust-system.h" namespace Rust { namespace AST { @@ -4723,22 +4723,20 @@ enum class InlineAsmOption struct AnonConst { NodeId id; - std::unique_ptr<Expr> value; + std::unique_ptr<Expr> expr; AnonConst () {} AnonConst (const AnonConst &other) { id = other.id; - value = other.value == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.value->clone_expr ()); + if (other.expr) + expr = other.expr->clone_expr (); } AnonConst operator= (const AnonConst &other) { id = other.id; - value = other.value == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.value->clone_expr ()); + if (other.expr) + expr = other.expr->clone_expr (); return *this; } }; @@ -4763,7 +4761,7 @@ struct InlineAsmRegOrRegClass Type type; struct Reg reg; - struct RegClass regClass; + struct RegClass reg_class; Identifier name; location_t locus; @@ -4790,17 +4788,15 @@ struct InlineAsmOperand In (const struct In &other) { reg = other.reg; - expr = other.expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.expr->clone_expr ()); + if (other.expr) + expr = other.expr->clone_expr (); } In operator= (const struct In &other) { reg = other.reg; - expr = other.expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.expr->clone_expr ()); + if (other.expr) + expr = other.expr->clone_expr (); return *this; } @@ -4817,18 +4813,16 @@ struct InlineAsmOperand { reg = other.reg; late = other.late; - expr = other.expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.expr->clone_expr ()); + if (other.expr) + expr = other.expr->clone_expr (); } Out operator= (const struct Out &other) { reg = other.reg; late = other.late; - expr = other.expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.expr->clone_expr ()); + if (other.expr) + expr = other.expr->clone_expr (); return *this; } }; @@ -4844,18 +4838,17 @@ struct InlineAsmOperand { reg = other.reg; late = other.late; - expr = other.expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.expr->clone_expr ()); + if (other.expr) + expr = other.expr->clone_expr (); } InOut operator= (const struct InOut &other) { reg = other.reg; late = other.late; - expr = other.expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.expr->clone_expr ()); + if (other.expr) + expr = other.expr->clone_expr (); + return *this; } }; @@ -4872,24 +4865,23 @@ struct InlineAsmOperand { reg = other.reg; late = other.late; - in_expr = other.in_expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.in_expr->clone_expr ()); - out_expr = other.out_expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.out_expr->clone_expr ()); + if (other.in_expr) + in_expr = other.in_expr->clone_expr (); + + if (other.out_expr) + out_expr = other.out_expr->clone_expr (); } SplitInOut operator= (const struct SplitInOut &other) { reg = other.reg; late = other.late; - in_expr = other.in_expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.in_expr->clone_expr ()); - out_expr = other.out_expr == nullptr - ? nullptr - : std::unique_ptr<Expr> (other.out_expr->clone_expr ()); + + if (other.in_expr) + in_expr = other.in_expr->clone_expr (); + + if (other.out_expr) + out_expr = other.out_expr->clone_expr (); return *this; } @@ -4902,33 +4894,35 @@ struct InlineAsmOperand struct Sym { - std::unique_ptr<Expr> sym; + std::unique_ptr<Expr> expr; Sym () {} Sym (const struct Sym &other) { - sym = std::unique_ptr<Expr> (other.sym->clone_expr ()); + if (other.expr) + expr = std::unique_ptr<Expr> (other.expr->clone_expr ()); } Sym operator= (const struct Sym &other) { - sym = std::unique_ptr<Expr> (other.sym->clone_expr ()); + if (other.expr) + expr = std::unique_ptr<Expr> (other.expr->clone_expr ()); return *this; } }; - RegisterType registerType; + RegisterType register_type; struct In in; struct Out out; - struct InOut inOut; - struct SplitInOut splitInOut; + struct InOut in_out; + struct SplitInOut split_in_out; struct Const cnst; struct Sym sym; InlineAsmOperand () {} InlineAsmOperand (const InlineAsmOperand &other) - : in (other.in), out (other.out), inOut (other.inOut), - splitInOut (other.splitInOut), cnst (other.cnst), sym (other.sym) + : in (other.in), out (other.out), in_out (other.in_out), + split_in_out (other.split_in_out), cnst (other.cnst), sym (other.sym) {} location_t locus; |