aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-11-08 00:57:51 +0000
committerPhilip Herron <philip.herron@embecosm.com>2021-11-16 14:19:22 +0000
commit432add899f4e436d0d30b89ef87fe19e71b36955 (patch)
treef8319a2b9e0873c080a74dedddf0446ecb77540d /gcc/rust/backend
parent694cf0251226348b64d885cfb378f775ff2a0d58 (diff)
downloadgcc-432add899f4e436d0d30b89ef87fe19e71b36955.zip
gcc-432add899f4e436d0d30b89ef87fe19e71b36955.tar.gz
gcc-432add899f4e436d0d30b89ef87fe19e71b36955.tar.bz2
Revert desugaring of CompoundAssignment into arithmetic operation and assignment
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-expr.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h
index c9d3c30..8ed84c7 100644
--- a/gcc/rust/backend/rust-compile-expr.h
+++ b/gcc/rust/backend/rust-compile-expr.h
@@ -388,6 +388,23 @@ public:
ctx->add_statement (assignment);
}
+ void visit (HIR::CompoundAssignmentExpr &expr) override
+ {
+ fncontext fn = ctx->peek_fn ();
+ auto lvalue = CompileExpr::Compile (expr.get_left_expr ().get (), ctx);
+ auto rvalue = CompileExpr::Compile (expr.get_right_expr ().get (), ctx);
+
+ auto op = expr.get_expr_type ();
+ auto operator_expr = ctx->get_backend ()->arithmetic_or_logical_expression (
+ op, lvalue, rvalue, expr.get_locus ());
+
+ Bstatement *assignment
+ = ctx->get_backend ()->assignment_statement (fn.fndecl, lvalue,
+ operator_expr,
+ expr.get_locus ());
+ ctx->add_statement (assignment);
+ }
+
void visit (HIR::ArrayIndexExpr &expr) override
{
Bexpression *array = CompileExpr::Compile (expr.get_array_expr (), ctx);