[jit] Add emulation r4 to u8 conversion. Fixes #31582.
authorRodrigo Kumpera <kumpera@gmail.com>
Fri, 3 Jul 2015 18:32:04 +0000 (14:32 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 3 Jul 2015 18:32:04 +0000 (14:32 -0400)
Most targets, like arm and amd64 don't support fast float to ulong conversion.

mono/mini/basic-float.cs
mono/mini/jit-icalls.c
mono/mini/jit-icalls.h
mono/mini/mini-runtime.c

index a5ccf787e73886fa0747e3d6feb2b0811bfc1e52..0eb1e240bc5348d18f4d81badc38b476dee69152 100644 (file)
@@ -812,5 +812,13 @@ class Tests
                short b = (short)a;
                return b == 127 ? 0 : 1;
        }
+
+       public static int test_10_rconv_to_u8 () {
+               ulong l = 10;
+               float f = (float)l;
+               l = (ulong)f;
+               return (int)l;
+       }
+
 }
 
index e0c9e31a941b18002533adefea0ffbcda6292e19..03f519a041ff4f18e30f8e57e6f5a6f538f2d9f7 100644 (file)
@@ -850,6 +850,12 @@ mono_fconv_u8 (double v)
        return (guint64)v;
 }
 
+guint64
+mono_rconv_u8 (float v)
+{
+       return (guint64)v;
+}
+
 #ifdef MONO_ARCH_EMULATE_FCONV_TO_I8
 gint64
 mono_fconv_i8 (double v)
index d31e06e63c5f99dd4511a227031563398f31594f..62acaed3c12d6074fb3b3e381cdb5081f572740a 100644 (file)
@@ -67,6 +67,8 @@ gpointer mono_ldtoken_wrapper_generic_shared (MonoImage *image, int token, MonoM
 
 guint64 mono_fconv_u8 (double v);
 
+guint64 mono_rconv_u8 (float v);
+
 gint64 mono_fconv_i8 (double v);
 
 guint32 mono_fconv_u4 (double v);
index b597688610482ec362dd8d1ea444b0caed4c75ab..0ae7a075d40ae508947b2442454e77367fa8e8d7 100644 (file)
@@ -3230,16 +3230,19 @@ register_icalls (void)
 #endif
 
        register_opcode_emulation (OP_FCONV_TO_U8, "__emul_fconv_to_u8", "ulong double", mono_fconv_u8, "mono_fconv_u8", FALSE);
+       register_opcode_emulation (OP_RCONV_TO_U8, "__emul_rconv_to_u8", "ulong float", mono_rconv_u8, "mono_rconv_u8", FALSE);
        register_opcode_emulation (OP_FCONV_TO_U4, "__emul_fconv_to_u4", "uint32 double", mono_fconv_u4, "mono_fconv_u4", FALSE);
        register_opcode_emulation (OP_FCONV_TO_OVF_I8, "__emul_fconv_to_ovf_i8", "long double", mono_fconv_ovf_i8, "mono_fconv_ovf_i8", FALSE);
        register_opcode_emulation (OP_FCONV_TO_OVF_U8, "__emul_fconv_to_ovf_u8", "ulong double", mono_fconv_ovf_u8, "mono_fconv_ovf_u8", FALSE);
        register_opcode_emulation (OP_RCONV_TO_OVF_I8, "__emul_rconv_to_ovf_i8", "long float", mono_rconv_ovf_i8, "mono_rconv_ovf_i8", FALSE);
        register_opcode_emulation (OP_RCONV_TO_OVF_U8, "__emul_rconv_to_ovf_u8", "ulong float", mono_rconv_ovf_u8, "mono_rconv_ovf_u8", FALSE);
 
+
 #ifdef MONO_ARCH_EMULATE_FCONV_TO_I8
        register_opcode_emulation (OP_FCONV_TO_I8, "__emul_fconv_to_i8", "long double", mono_fconv_i8, "mono_fconv_i8", FALSE);
        register_opcode_emulation (OP_RCONV_TO_I8, "__emul_rconv_to_i8", "long float", mono_rconv_i8, "mono_rconv_i8", FALSE);
 #endif
+
 #ifdef MONO_ARCH_EMULATE_CONV_R8_UN
        register_opcode_emulation (OP_ICONV_TO_R_UN, "__emul_iconv_to_r_un", "double int32", mono_conv_to_r8_un, "mono_conv_to_r8_un", FALSE);
 #endif