From 604de2018bde65f8bb49799f2794c1d834047855 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Thu, 21 May 2020 19:03:46 +0200 Subject: [PATCH] :art: stmt_loop var now in mem --- src/emit/emit.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/emit/emit.c b/src/emit/emit.c index 74016467..3263141f 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1501,17 +1501,20 @@ ANN static m_bool emit_stmt_auto(const Emitter emit, const Stmt_Auto stmt) { ANN static m_bool _emit_stmt_loop(const Emitter emit, const Stmt_Loop stmt, m_uint *index) { CHECK_BB(emit_exp_pop_next(emit, stmt->cond)) + const m_uint offset = emit_local(emit, emit->gwion->type[et_int]); + const Instr tomem = emit_add_instr(emit, Reg2Mem); + tomem->m_val = offset; + tomem->m_val2 = -SZ_INT; + regpop(emit, SZ_INT); *index = emit_code_size(emit); - const Instr cpy = emit_add_instr(emit, Reg2RegAddr); - cpy->m_val2 = -SZ_INT; - regpush(emit, SZ_INT); + const Instr cpy = emit_add_instr(emit, RegPushMem4); + cpy->m_val = offset; emit_add_instr(emit, int_post_dec); const Instr op = emit_add_instr(emit, BranchEqInt); CHECK_BB(scoped_stmt(emit, stmt->body, 1)) const Instr _goto = emit_add_instr(emit, Goto); _goto->m_val = *index; op->m_val = emit_code_size(emit); - regpop(emit, SZ_INT); return GW_OK; } -- 2.43.0