Blob Blame History Raw
From d26a313ae92bb515b04865b6a71a63701dd1fe41 Mon Sep 17 00:00:00 2001
From: Xavier Leroy <xavier.leroy@college-de-france.fr>
Date: Thu, 30 Apr 2020 16:18:06 +0200
Subject: [PATCH 6/7] Support FP reg -> int reg moves

Using instruction fmv.x.d.

This is necessary to implement the ELF psABI calling conventions,
whereas some FP arguments may have to be passed in integer registers.

(cherry picked from commit 16794b940555315c723411077a2902fc85a33c45)
---
 asmcomp/riscv/emit.mlp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/asmcomp/riscv/emit.mlp b/asmcomp/riscv/emit.mlp
index dc652de42..dbfdc2d40 100644
--- a/asmcomp/riscv/emit.mlp
+++ b/asmcomp/riscv/emit.mlp
@@ -283,8 +283,10 @@ let emit_instr i =
         match (src, dst) with
         | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Reg _} ->
             `	mv      {emit_reg dst}, {emit_reg src}\n`
-        | {loc = Reg _; typ = Float}, {loc = Reg _} ->
+        | {loc = Reg _; typ = Float}, {loc = Reg _; typ = Float} ->
             `	fmv.d   {emit_reg dst}, {emit_reg src}\n`
+        | {loc = Reg _; typ = Float}, {loc = Reg _; typ = (Val | Int | Addr)} ->
+            `	fmv.x.d {emit_reg dst}, {emit_reg src}\n`
         | {loc = Reg _; typ = (Val | Int | Addr)}, {loc = Stack s} ->
             let ofs = slot_offset s (register_class dst) in
             emit_store src ofs
-- 
2.24.1