+2005-12-13 Aleksey Demakov <ademakov@gmail.com>
+
+ * configure.in: Added --enable-long-double option that forces
+ jit_nfloat to be long double.
+
+ * jit/jit-apply-x86.h (jit_builtin_apply, jit_builtin_return_float):
+ In gcc/Win32 and gcc/non-Win32 versions of the macros check the size
+ of jit_nfloat and use fstpl/fldl or fstpt/fldt instructions
+ accordingly.
+
+ * tools/gen-apply.c (detect_float_return): On x86 only the first
+ 10 bytes of 12 byte long doubles are significant and are used for
+ comparison.
+
2005-12-12 Aleksey Demakov <ademakov@gmail.com>
- * jit/jit-dump.c (dump_object_code): in order to make dump work on cygwin
- call "as" and "objdump" in two separate system() calls because it looks
- like the ';' separator between commands does not work there. Also on Win32
- use TMP and TEMP environment variables as the tmp directory names and
- fallback to "c:/tmp".
+ * jit/jit-dump.c (dump_object_code): in order to make dump work on
+ cygwin call "as" and "objdump" in two separate system() calls because
+ it looks like the ';' separator between commands does not work there.
+ Also on Win32 use TMP and TEMP environment variables as the tmp
+ directory names and fallback to "c:/tmp".
- * jit/jit-gen-x86.h (jit_assert): change definition to resolve problems
- introduced at 2005-12-10.
+ * jit/jit-gen-x86.h (jit_assert): change the macro definition to
+ resolve problems introduced at 2005-12-10.
2005-12-10 Aleksey Demakov <ademakov@gmail.com>
- * jit/jit-gen-x86.h: Merged changes from the latest Mono project's version
- of this file.
+ * jit/jit-gen-x86.h: Merged changes from the latest Mono project's
+ version of this file.
* jit/jit-rules-x86.sel: Done the following rules:
JIT_OP_LOAD_ELEMENT_FLOAT32, JIT_OP_LOAD_ELEMENT_FLOAT64,
AC_DEFINE(USE_LIBJIT_INTERPRETER, 1, [Define if you want to use the libjit interpreter])
fi
+dnl The "--enable-long-double" option forces the use of long double for
+dnl jit_nfloat.
+AC_ARG_ENABLE(long-double,
+[ --enable-long-double Enable the use of long double for jit_nfloat])
+
dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_MSG_RESULT($JITFLOAT64)
AC_MSG_CHECKING(for the native floating-point type)
JITNFLOATISDOUBLE=''
-if test "x$platform_win32" = "xyes" ; then
+if test "$ac_cv_sizeof_long_double" != 0 ; then
dnl MSVC's "long double" is the same as "double", so we make sure
- dnl to preserve compatibility between MSVC and gcc.
- JITNATIVEFLOAT='double'
- JITNFLOATISDOUBLE='#define JIT_NFLOAT_IS_DOUBLE 1'
-elif test "$ac_cv_sizeof_long_double" != 0 ; then
- if test "$ac_cv_sizeof_long_double" = "$ac_cv_sizeof_double" ; then
+ dnl to preserve compatibility between MSVC and gcc unless the
+ dnl --enable-long-double option is provided.
+ if test "x$enable_long_double" = "xyes" ; then
+ JITNATIVEFLOAT='long double'
+ elif test "x$enable_long_double" = "xno" -o "$ac_cv_sizeof_long_double" = "$ac_cv_sizeof_double" -o "x$platform_win32" = "xyes" ; then
JITNATIVEFLOAT='double'
JITNFLOATISDOUBLE='#define JIT_NFLOAT_IS_DOUBLE 1'
else
); \
if((return_float)) \
{ \
- __asm__ ( \
- "movl %0, %%ecx\n\t" \
- "fstpt 8(%%ecx)\n\t" \
- : : "m"(__return_buf) \
- : "ecx", "st" \
- ); \
- } \
+ if(sizeof(jit_nfloat) == sizeof(double)) \
+ { \
+ __asm__ ( \
+ "movl %0, %%ecx\n\t" \
+ "fstpl 8(%%ecx)\n\t" \
+ : : "m"(__return_buf) \
+ : "ecx", "st" \
+ ); \
+ } \
+ else \
+ { \
+ __asm__ ( \
+ "movl %0, %%ecx\n\t" \
+ "fstpt 8(%%ecx)\n\t" \
+ : : "m"(__return_buf) \
+ : "ecx", "st" \
+ ); \
+ } \
+ } \
} while (0)
#define jit_builtin_apply_args(type,args) \
); \
if((return_float)) \
{ \
- __asm__ ( \
- "movl %0, %%ecx\n\t" \
- "fstpt 8(%%ecx)\n\t" \
- : : "m"(__return_buf) \
- : "ecx", "st" \
- ); \
+ if(sizeof(jit_nfloat) == sizeof(double)) \
+ { \
+ __asm__ ( \
+ "movl %0, %%ecx\n\t" \
+ "fstpl 8(%%ecx)\n\t" \
+ : : "m"(__return_buf) \
+ : "ecx", "st" \
+ ); \
+ } \
+ else \
+ { \
+ __asm__ ( \
+ "movl %0, %%ecx\n\t" \
+ "fstpt 8(%%ecx)\n\t" \
+ : : "m"(__return_buf) \
+ : "ecx", "st" \
+ ); \
+ } \
} \
} while (0)
#define jit_builtin_return_float(return_buf) \
do { \
- double __value = \
+ jit_nfloat __value = \
((jit_apply_return *)(return_buf))-> \
f_value.inner_value.nfloat_value; \
- __asm__ ( \
- "leal %0, %%ecx\n\t" \
- "fldl (%%ecx)\n\t" \
- : : "m"(__value) \
- : "ecx", "st" \
- ); \
+ if(sizeof(jit_nfloat) == sizeof(double)) \
+ { \
+ __asm__ ( \
+ "leal %0, %%ecx\n\t" \
+ "fldl (%%ecx)\n\t" \
+ : : "m"(__value) \
+ : "ecx", "st" \
+ ); \
+ } \
+ else \
+ { \
+ __asm__ ( \
+ "leal %0, %%ecx\n\t" \
+ "fldt (%%ecx)\n\t" \
+ : : "m"(__value) \
+ : "ecx", "st" \
+ ); \
+ } \
return; \
} while (0)
#define PLATFORM_IS_X86_64 1
#endif
+/*
+ * On x86 the extended precision numbers are 10 bytes long. However certain
+ * ABIs define the long double size equal to 12 bytes. The extra 2 bytes are
+ * for alignment purposes only and has no significance in computations.
+ */
+#if PLATFORM_IS_X86
+#define NFLOAT_SIGNIFICANT_BYTES (sizeof(jit_nfloat) != 12 ? sizeof(jit_nfloat) : 10)
+#else
+#define NFLOAT_SIGNIFICANT_BYTES sizeof(jit_nfloat)
+#endif
+
#if defined(PLATFORM_IS_GCC) || defined(PLATFORM_IS_WIN32)
/*
mem_copy(&nfloat_value, return_value + offset,
sizeof(jit_nfloat));
temp_nfloat = (jit_nfloat)123.0;
- if(!mem_cmp(&nfloat_value, &temp_nfloat, sizeof(jit_nfloat)))
+ if(!mem_cmp(&nfloat_value, &temp_nfloat, NFLOAT_SIGNIFICANT_BYTES))
{
break;
}