From 5cbe03b9c47e676e045b4978c384087433bd6042 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sat, 1 Feb 2014 12:29:51 +0800 Subject: [PATCH] Move result of itof double conv back to VFP reg EABI functions to convert an int to a double register take the integer value in core registers and also give the result in core registers. It is thus necessary to move the result back to VFP register after the function call. This only affected integer to double conversion because integer to float conversion used a VFP instruction to do the conversion and this obviously left the result in VFP register. Note that the behavior is left untouched for !EABI as the correct behavior in this case is unknown to the author of this patch. --- Changelog | 1 + arm-gen.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Changelog b/Changelog index 9a497cf3..20814c10 100644 --- a/Changelog +++ b/Changelog @@ -65,6 +65,7 @@ Bug fixes: - fix NaN comparison (Thomas Preud'homme) - use libtcc for static linking with runtime library (Thomas Preud'homme) - fix negation of 0.0 and -0.0 values (Thomas Preud'homme) +- fix integer to double conversion on ARM (Thomas Preud'homme) version 0.9.26: diff --git a/arm-gen.c b/arm-gen.c index 9611dca6..c746e91f 100644 --- a/arm-gen.c +++ b/arm-gen.c @@ -1979,8 +1979,17 @@ ST_FUNC void gen_cvt_itof1(int t) vpush_global_sym(func_type, func); vswap(); gfunc_call(1); +#if defined(TCC_ARM_VFP) && defined(TCC_ARM_EABI) + r=get_reg(RC_FLOAT); + r2=vfpr(r); + o(0xEE000B10|(r2<<16)); /* vmov.32 dr2[0], r0 */ + o(0xEE201B10|(r2<<16)); /* vmov.32 dr2[1], r1 */ + vpushi(0); + vtop->r=r; +#else vpushi(0); vtop->r=TREG_F0; +#endif return; } } -- 2.11.4.GIT