harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 6f196a6391bc882250297db898e70252968ae4f9
parent 5cd989b97697ecd43994d77480a29a3e456890f4
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed,  4 Aug 2021 21:47:05 +0200

gen: use gen_expr_at for assignment

Saves a copy+alloc!

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Msrc/gen.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gen.c b/src/gen.c @@ -302,7 +302,7 @@ gen_expr_assign(struct gen_context *ctx, const struct expression *expr) obj = gen_expr_access_addr(ctx, object); } if (expr->assign.op == BIN_LEQUAL) { - gen_store(ctx, obj, gen_expr(ctx, value)); + gen_expr_at(ctx, value, obj); } else if (expr->assign.op == BIN_LAND || expr->assign.op == BIN_LOR) { assert(0); // TODO } else { @@ -310,8 +310,8 @@ gen_expr_assign(struct gen_context *ctx, const struct expression *expr) struct gen_value rvalue = gen_expr(ctx, value); struct qbe_value qlval = mkqval(ctx, &lvalue); struct qbe_value qrval = mkqval(ctx, &rvalue); - enum qbe_instr instr = binarithm_for_op(ctx, expr->assign.op, - lvalue.type); + enum qbe_instr instr = binarithm_for_op(ctx, + expr->assign.op, lvalue.type); pushi(ctx->current, &qlval, instr, &qlval, &qrval, NULL); gen_store(ctx, obj, lvalue); }