projects
/
mono.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
67385bd
)
Move the imul/idiv/irem emulation code out of #ifndef MONO_ARCH_NO_EMULATE_LONG_MUL_OPTS.
author
Zoltan Varga
<vargaz@gmail.com>
Fri, 7 Sep 2012 21:02:25 +0000
(23:02 +0200)
committer
Zoltan Varga
<vargaz@gmail.com>
Fri, 7 Sep 2012 21:02:25 +0000
(23:02 +0200)
mono/mini/jit-icalls.c
patch
|
blob
|
history
diff --git
a/mono/mini/jit-icalls.c
b/mono/mini/jit-icalls.c
index 2f75e4301b5e28c9a6077afa56d9ee461dc135e3..7f485f74f2a9da6ae01c23046bbcfc4000cd6860 100644
(file)
--- a/
mono/mini/jit-icalls.c
+++ b/
mono/mini/jit-icalls.c
@@
-234,51
+234,48
@@
mono_llmult_ovf (gint64 a, gint64 b)
return 0;
}
return 0;
}
-#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_EMULATE_DIV)
-
-gint32
-mono_idiv (gint32 a, gint32 b)
+gint64
+mono_lldiv (gint64 a, gint64 b)
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
- else if (b == -1 && a == (
0x80000000
))
- mono_raise_exception (mono_get_exception_
overflow
());
+ else if (b == -1 && a == (
-9223372036854775807LL - 1LL
))
+ mono_raise_exception (mono_get_exception_
arithmetic
());
#endif
return a / b;
}
#endif
return a / b;
}
-g
uint32
-mono_
idiv_un (guint32 a, guint32
b)
+g
int64
+mono_
llrem (gint64 a, gint64
b)
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
+ else if (b == -1 && a == (-9223372036854775807LL - 1LL))
+ mono_raise_exception (mono_get_exception_arithmetic ());
#endif
#endif
- return a
/
b;
+ return a
%
b;
}
}
-g
int32
-mono_
irem (gint32 a, gint32
b)
+g
uint64
+mono_
lldiv_un (guint64 a, guint64
b)
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
- else if (b == -1 && a == (0x80000000))
- mono_raise_exception (mono_get_exception_overflow ());
#endif
#endif
-
- return a % b;
+ return a / b;
}
}
-guint
32
-mono_
irem_un (guint32 a, guint32
b)
+guint
64
+mono_
llrem_un (guint64 a, guint64
b)
{
MONO_ARCH_SAVE_REGS;
{
MONO_ARCH_SAVE_REGS;
@@
-291,99
+288,94
@@
mono_irem_un (guint32 a, guint32 b)
#endif
#endif
-#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_EMULATE_MUL_OVF)
-
-gint32
-mono_imul (gint32 a, gint32 b)
-{
- MONO_ARCH_SAVE_REGS;
-
- return a * b;
-}
+#ifndef MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS
-g
int32
-mono_
imul_ovf (gint32 a, gint32 b
)
+g
uint64
+mono_
lshl (guint64 a, gint32 shamt
)
{
{
- gint64 res;
-
- MONO_ARCH_SAVE_REGS;
+ guint64 res;
- res = (gint64)a * (gint64)b;
+ /* no need, no exceptions: MONO_ARCH_SAVE_REGS;*/
+ res = a << shamt;
- if ((res > 0x7fffffffL) || (res < -2147483648LL))
- mono_raise_exception (mono_get_exception_overflow ());
+ /*printf ("TESTL %lld << %d = %lld\n", a, shamt, res);*/
return res;
}
return res;
}
-g
int32
-mono_
imul_ovf_un (guint32 a, guint32 b
)
+g
uint64
+mono_
lshr_un (guint64 a, gint32 shamt
)
{
guint64 res;
{
guint64 res;
- MONO_ARCH_SAVE_REGS;
-
- res = (guint64)a * (guint64)b;
+ /* no need, no exceptions: MONO_ARCH_SAVE_REGS;*/
+ res = a >> shamt;
- if ((res >> 32))
- mono_raise_exception (mono_get_exception_overflow ());
+ /*printf ("TESTR %lld >> %d = %lld\n", a, shamt, res);*/
return res;
}
return res;
}
-#endif
-#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_SOFT_FLOAT)
-double
-mono_fdiv (double a, double b)
+gint64
+mono_lshr (gint64 a, gint32 shamt)
{
{
-
MONO_ARCH_SAVE_REGS
;
+
gint64 res
;
- return a / b;
+ /* no need, no exceptions: MONO_ARCH_SAVE_REGS;*/
+ res = a >> shamt;
+
+ /*printf ("TESTR %lld >> %d = %lld\n", a, shamt, res);*/
+
+ return res;
}
}
+
#endif
#endif
-gint64
-mono_lldiv (gint64 a, gint64 b)
+#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_EMULATE_DIV)
+
+gint32
+mono_idiv (gint32 a, gint32 b)
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
- else if (b == -1 && a == (
-9223372036854775807LL - 1LL
))
- mono_raise_exception (mono_get_exception_
arithmetic
());
+ else if (b == -1 && a == (
0x80000000
))
+ mono_raise_exception (mono_get_exception_
overflow
());
#endif
return a / b;
}
#endif
return a / b;
}
-g
int64
-mono_
llrem (gint64 a, gint64
b)
+g
uint32
+mono_
idiv_un (guint32 a, guint32
b)
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
- else if (b == -1 && a == (-9223372036854775807LL - 1LL))
- mono_raise_exception (mono_get_exception_arithmetic ());
#endif
#endif
- return a
%
b;
+ return a
/
b;
}
}
-g
uint64
-mono_
lldiv_un (guint64 a, guint64
b)
+g
int32
+mono_
irem (gint32 a, gint32
b)
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
{
MONO_ARCH_SAVE_REGS;
#ifdef MONO_ARCH_NEED_DIV_CHECK
if (!b)
mono_raise_exception (mono_get_exception_divide_by_zero ());
+ else if (b == -1 && a == (0x80000000))
+ mono_raise_exception (mono_get_exception_overflow ());
#endif
#endif
- return a / b;
+
+ return a % b;
}
}
-guint
64
-mono_
llrem_un (guint64 a, guint64
b)
+guint
32
+mono_
irem_un (guint32 a, guint32
b)
{
MONO_ARCH_SAVE_REGS;
{
MONO_ARCH_SAVE_REGS;
@@
-396,47
+388,55
@@
mono_llrem_un (guint64 a, guint64 b)
#endif
#endif
-#if
ndef MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS
+#if
defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_EMULATE_MUL_OVF)
-g
uint64
-mono_
lshl (guint64 a, gint32 shamt
)
+g
int32
+mono_
imul (gint32 a, gint32 b
)
{
{
- guint64 res;
-
- /* no need, no exceptions: MONO_ARCH_SAVE_REGS;*/
- res = a << shamt;
-
- /*printf ("TESTL %lld << %d = %lld\n", a, shamt, res);*/
+ MONO_ARCH_SAVE_REGS;
- return
res
;
+ return
a * b
;
}
}
-g
uint64
-mono_
lshr_un (guint64 a, gint32 shamt
)
+g
int32
+mono_
imul_ovf (gint32 a, gint32 b
)
{
{
- g
u
int64 res;
+ gint64 res;
- /* no need, no exceptions: MONO_ARCH_SAVE_REGS;*/
- res = a >> shamt;
+ MONO_ARCH_SAVE_REGS;
- /*printf ("TESTR %lld >> %d = %lld\n", a, shamt, res);*/
+ res = (gint64)a * (gint64)b;
+
+ if ((res > 0x7fffffffL) || (res < -2147483648LL))
+ mono_raise_exception (mono_get_exception_overflow ());
return res;
}
return res;
}
-gint
64
-mono_
lshr (gint64 a, gint32 shamt
)
+gint
32
+mono_
imul_ovf_un (guint32 a, guint32 b
)
{
{
- gint64 res;
+ g
u
int64 res;
- /* no need, no exceptions: MONO_ARCH_SAVE_REGS;*/
- res = a >> shamt;
+ MONO_ARCH_SAVE_REGS;
- /*printf ("TESTR %lld >> %d = %lld\n", a, shamt, res);*/
+ res = (guint64)a * (guint64)b;
+
+ if ((res >> 32))
+ mono_raise_exception (mono_get_exception_overflow ());
return res;
}
return res;
}
+#endif
+
+#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_SOFT_FLOAT)
+double
+mono_fdiv (double a, double b)
+{
+ MONO_ARCH_SAVE_REGS;
+ return a / b;
+}
#endif
#ifdef MONO_ARCH_SOFT_FLOAT
#endif
#ifdef MONO_ARCH_SOFT_FLOAT