Signed-off-by: Arthur Huillet <[email protected]>
---
include/jit/emulate.h | 2 ++
jit/emulate.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/include/jit/emulate.h b/include/jit/emulate.h
index c042871..d797eb7 100644
--- a/include/jit/emulate.h
+++ b/include/jit/emulate.h
@@ -4,5 +4,7 @@
int emulate_lcmp(long long value1, long long value2);
long long emulate_ldiv(long long value1, long long value2);
long long emulate_lrem(long long value1, long long value2);
+int emulate_fcmpl(float value1, float value2);
+int emulate_fcmpg(float value1, float value2);
#endif /* __JIT_EMULATE_H */
diff --git a/jit/emulate.c b/jit/emulate.c
index 6cd7448..9d7b46b 100644
--- a/jit/emulate.c
+++ b/jit/emulate.c
@@ -24,6 +24,7 @@
* Please refer to the file LICENSE for details.
*/
+#include <math.h>
#include <jit/exception.h>
#include <jit/emulate.h>
#include <vm/class.h>
@@ -39,6 +40,35 @@ int emulate_lcmp(long long value1, long long value2)
return 0;
}
+static int __emulate_fcmpx(float value1, float value2)
+{
+ float tmp;
+ tmp = value1 - value2;
+
+ if (tmp < 0)
+ return -1;
+ else if (tmp > 0)
+ return 1;
+
+ return 0;
+}
+
+int emulate_fcmpl(float value1, float value2)
+{
+ if (isnan(value1) || isnan(value2))
+ return -1;
+
+ return __emulate_fcmpx(value1, value2);
+}
+
+int emulate_fcmpg(float value1, float value2)
+{
+ if (isnan(value1) || isnan(value2))
+ return 1;
+
+ return __emulate_fcmpx(value1, value2);
+}
+
long long emulate_ldiv(long long value1, long long value2)
{
if (value2 == 0) {
--
1.6.3.3
------------------------------------------------------------------------------
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel