From 9f81982d868cb15dbc374c424d563d41fc47e618 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 21 Feb 2023 11:42:05 +0300 Subject: [PATCH] Fix 'mov' to/from 'sp' register sp is shared with zero register and 'mov' for sp/xzr is encoded differently --- ir_aarch64.dasc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ir_aarch64.dasc b/ir_aarch64.dasc index d87a366..ef41841 100644 --- a/ir_aarch64.dasc +++ b/ir_aarch64.dasc @@ -1193,7 +1193,13 @@ static void ir_emit_mov(ir_ctx *ctx, ir_type type, ir_reg dst, ir_reg src) dasm_State **Dst = &data->dasm_state; if (ir_type_size[type] == 8) { - | mov Rx(dst), Rx(src) + if (dst == IR_REG_STACK_POINTER) { + | mov sp, Rx(src) + } else if (src == IR_REG_STACK_POINTER) { + | mov Rx(dst), sp + } else { + | mov Rx(dst), Rx(src) + } } else { | mov Rw(dst), Rw(src) }