From e2810c070e27f6c5334841c0d9a9f660662c7047 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 28 Feb 2023 18:12:29 +0300 Subject: [PATCH] Save and restore used non-volatile XMM registers in prologue and epilogue. We currently save only "single double" part of the registers using "movsd" instruction. In general, we should save and restore the whole XMM registers. --- ir_x86.dasc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ir_x86.dasc b/ir_x86.dasc index e6bec49..0879ca5 100644 --- a/ir_x86.dasc +++ b/ir_x86.dasc @@ -2061,7 +2061,10 @@ static void ir_emit_prologue(ir_ctx *ctx) offset -= sizeof(void*); | mov aword [Ra(fp)+offset], Ra(i) } else { - IR_ASSERT(0 && "NIY FP register saing"); + ir_reg fp = (ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FRAME_POINTER : IR_REG_STACK_POINTER; + + offset -= sizeof(void*); + | movsd qword [Ra(fp)+offset], xmm(i-IR_REG_FP_FIRST) } } } @@ -2090,7 +2093,10 @@ static void ir_emit_epilogue(ir_ctx *ctx) offset -= sizeof(void*); | mov Ra(i), aword [Ra(fp)+offset] } else { - IR_ASSERT(0 && "NIY FP register saing"); + ir_reg fp = (ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FRAME_POINTER : IR_REG_STACK_POINTER; + + offset -= sizeof(void*); + | movsd xmm(i-IR_REG_FP_FIRST), qword [Ra(fp)+offset] } } }